mode.utils.aiter
¶
Async iterator lost and found missing methods: aiter, anext, etc.
-
mode.utils.aiter.
aenumerate
(it: AsyncIterable[Any], start: int = 0) → AsyncIterator[Tuple[int, Any]][source]¶ async for
version ofenumerate
.
-
mode.utils.aiter.
aiter
(it: Any) → AsyncIterator[source]¶ Create iterator from iterable.
Notes
If the object is already an iterator, the iterator should return self when
__aiter__
is called.
-
class
mode.utils.aiter.
arange
(*slice_args: int, **slice_kwargs: Any)[source]¶ Async generator that counts like
range
.
-
mode.utils.aiter.
chunks
(it: AsyncIterable, n: int) → AsyncIterable[List][source]¶ Split an async iterator into chunks with n elements each.
Example
# n == 2 >>> x = chunks(arange(10), 2) >>> [item async for item in x] [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10]]
# n == 3 >>> x = chunks(arange(10)), 3) >>> [item async for item in x] [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10]]