aioplus.aislice

aioplus.aislice(aiterable, start, stop=None, step=None, /)

Return selected elements from the iterable.

Parameters:
  • aiterable (AsyncIterable of T) – An asynchronous iterable of objects to slice.

  • start (int) – The index of the first object to include. If stop is None, treated as the end index, and slicing starts from 0.

  • stop (int, optional) – The index at which to stop (exclusive). If not provided, start is interpreted as stop, and slicing starts from 0.

  • step (int, optional) – The difference between consecutive values. Defaults to 1.

Returns:

An asynchronous iterable yielding selected objects according to the slice parameters.

Return type:

AsyncIterable of T

Examples

>>> aiterable = arange(2003)
>>> [num async for num in aislice(aiterable, 4, 23)]
[4, 5, 6, 7, 8, ..., 20, 21, 22]