aioplus.ahead

aioplus.ahead(aiterable, /, *, n)

Return the first n items of the aiterable.

Parameters:
  • aiterable (AsyncIterable[T]) – An asynchronous iterable to retrieve items from.

  • n (int) – The number of items to retrieve from the start.

Returns:

An asynchronous iterable yielding the first n items of the aiterable.

Return type:

AsyncIterable[T]

Examples

>>> aiterable = arange(23)
>>> [num async for num in ahead(aiterable, n=4)]
[0, 1, 2, 3]