asyncutils.iterclasses¶
Object-oriented (async) iteration helpers.
Classes¶
Async version of |
|
Async version of |
|
Async version of |
Module Contents¶
- class asyncutils.iterclasses.abucket[T, R](
- it: asyncutils._internal.types.SupportsIteration[T],
- key: collections.abc.Callable[[T], R],
- validator: collections.abc.Callable[[R], bool],
Bases:
asyncutils.mixins.LoopContextMixinAsync version of
more_itertools.bucket.Divide items from the (async) iterable
itinto child generators according to akeyfunction.- __aiter__() collections.abc.AsyncGenerator[T][source]¶
Yield the keys of all buckets. When this async generator is exhausted, the original iterable is fully consumed. Unlike the sync version, an exhausted bucket has no keys.
- __getitem__(key: R, /) collections.abc.AsyncGenerator[T][source]¶
Return an async generator of the items in the original iterable for which the key function gives this key.
- class asyncutils.iterclasses.achain[T][source]¶
Async version of
itertools.chainthat takes async or sync iterables.Construct an
achainfrom the (async) iterables.- __aiter__() collections.abc.AsyncGenerator[T][source]¶
Yield items from the first iterable until exhausted, then start on the second, etc.
- classmethod from_iterable(
- it_of_its: asyncutils._internal.types.SupportsIteration[asyncutils._internal.types.SupportsIteration[T]],
Construct an
achainfromit_of_its, an (async) iterable of (async) iterables to chain.Tip
Since the outer iterable is advanced on demand, a possible use case would be to combine chunks of items from different sources as they arrive.
- class asyncutils.iterclasses.apeekable[T][source]¶
- class asyncutils.iterclasses.apeekable(it: asyncutils._internal.types.SupportsIteration[T])
Bases:
asyncutils._internal.helpers.LoopMixinBaseAsync version of
more_itertools.peekable.Wraps an (async) iterable in an asynchronous iterator and sequence APIs, supporting lookahead and prependage.
- async __getitem__(idx: asyncutils._internal.types.ValidSlice, /) tuple[T, Ellipsis][source]¶
- async __getitem__(idx: SupportsIndex, /) T
Slice or index access. Must be awaited.
- async can_peek() bool[source]¶
Check whether any items are left in the underlying iterable without advancing it.