aioplus.awindowed

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

Return a sliding window of width n over the given aiterable.

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

>>> aiterable = arange(23)
>>> [window async for window in awindowed(aiterable, n=3)]
[(0, 1, 2), (1, 2, 3), ..., (19, 20, 21), (20, 21, 22)]