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.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], R],
- validator: collections.abc.Callable[[R], bool] | None = ...,
Bases:
asyncutils.mixins.LoopContextMixinAsync version of
more_itertools.bucket().Divide items from the (async) iterable
itinto child generators according to akeyfunction.- __aiter__() types.AsyncGeneratorType[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.
- class asyncutils.iterclasses.AChain[T][source]¶
Async version of
chain()that takes async or sync iterables.Construct an
AChainfrom the (async) iterables.- __aiter__() types.AsyncGeneratorType[T][source]¶
Yield items from the first iterable until exhausted, then start on the second, etc.
- classmethod from_iterable(
- it_of_its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
Construct an
AChainfromit_of_its, an (async) iterable of (async) iterables to chain. If some iterables are chains themselves, their internal iterable of iterables are flattened into that of the returnedAChain, which may cause unexpected behaviour when iterating through these sources themselves.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.prots.SupportsIteration[T])
Bases:
asyncutils._internal.helpers.LoopMixinBaseAsync version of
more_itertools.peekable.Wrap an (async) iterable in an asynchronous iterator and sequence APIs, supporting lookahead and prepending.
- async __getitem__(idx: asyncutils._internal.prots.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.