aioplus.amin

async aioplus.amin(aiterable, /, *, key=None, default=<enum 'Sentinel'>)

Return the smallest item 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 (D, optional) – A default value to return if the iterable is empty.

Returns:

The smallest item in the iterable or the default value.

Return type:

T or D

Examples

>>> import asyncio
>>>
>>> from aioplus import amin, arange
>>>
>>> async def main() -> None:
>>>     '''Run the program.'''
>>>     aiterable = arange(23)
>>>     smallest = await amin(aiterable)
>>>     print(f'min(aiterable) == {smallest}')
>>>
>>> if __name__ == '__main__':
>>>     asyncio.run(main())

See also

min()