aioplus.awindowed¶
- aioplus.awindowed(aiterable, /, *, n)¶
Return a sliding window of width
nover the givenaiterable.- Parameters:
aiterable (AsyncIterable of T) – An asynchronous iterable of elements to be windowed.
n (int) –
- Returns:
An asynchronous iterable yielding windows of elements.
- Return type:
AsyncIterable of tuple[T, …]
Examples
>>> import asyncio >>> >>> from aioplus import arange, awindowed >>> >>> async def main() -> None: >>> '''Run the program.''' >>> async for window in awindowed(arange(23), n=4): >>> print(f'window = {window}') >>> >>> if __name__ == '__main__': >>> asyncio.run(main())