aioplus.atail¶
- aioplus.atail(aiterable, /, *, n)¶
Return the last
nitems of theaiterable.- 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
nitems of theaiterable.- Return type:
AsyncIterable[T]
Examples
>>> import asyncio >>> >>> from aioplus import arange, atail >>> >>> async def main() -> None: >>> '''Run the program.''' >>> async for num in atail(arange(23), n=4): >>> print(num) >>> >>> if __name__ == '__main__': >>> asyncio.run(main())
Notes
The last
nitems are buffered in memory before yielding;Yields control to the event loop before producing each value.