aioplus.awindowed

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

Return a sliding window of width n over aiterable.

Parameters:
  • aiterable (AsyncIterable[T]) – Iterable.

  • n (int) – Width.

Returns:

Iterator.

Return type:

AsyncIterator[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)]