aioplus.aminmax

async aioplus.aminmax(aiterable, /, *, key=None, default=<object object>)

Return the smallest and the largest items in aiterable.

Parameters:
  • aiterable (AsyncIterable[T]) – An asynchronous iterable of objects.

  • key (Callable[[T], SupportsRichComparison], optional) – A function that extracts a comparison key from each element in the iterable.

  • default (tuple[D1, D2], optional) – The default values to return if the iterable is empty.

Returns:

The smallest and the largest item in the iterable or the default values.

Return type:

tuple[T | D1, T | D2]

Examples

>>> aiterable = arange(23)
>>> await aminmax(aiterable)
(0, 22)

Notes

  • This function is not comparison-optimized.

See also

min(), max()