aioplus.atail

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

Return the last n items of the aiterable.

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

  • n (SupportsIndex) – The number of items to retrieve from the end.

Returns:

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

Return type:

AsyncIterable[T]

Examples

>>> aiterable = arange(23)
>>> [num async for num in atail(aiterable, n=4)]
[19, 20, 21, 22]

Notes

  • The last n items are buffered in memory before yielding;

  • Yields control to the event loop before producing each value.