asyncutils.iters¶
more_itertools, but some are unique to async.Classes¶
Functions¶
|
Async version of |
|
For each |
|
Async version of |
|
Whether all items in the (async) iterable are equal to each other according to the |
|
Return whether all the items in the (async) iterable |
|
Async version of |
|
Append |
|
Return the index of the first occurrence of the maximum element in the (async) iterable |
|
Return the index of the first occurrence of the minimum element in the (async) iterable |
|
Return a tuple of the indices of the first occurrences of the minimum and maximum elements in the (async) iterable |
|
Convert a function that returns an awaitable resolving to an async iterable into one returning an async generator. |
|
|
|
Breadth-first search on a start node |
|
|
|
Async version of |
|
Return a canonicalized ordering of the items in |
|
Yield the sent value, starting with |
|
Flatten the (async) iterable |
|
Async version of |
Async version of |
|
|
Async version of |
|
Advance the (async) iterable |
|
Polynomial multiplication with coefficients from the two iterables. The first iterable is advanced on demand, meaning it may be infinite, but the second iterable is exhausted immediately, storing all its items in memory. |
|
Async version of |
|
Yield tuples of the form |
|
Count down from |
|
Async version of |
|
Successive derangements of the elements in |
|
Depth-first search on a start node |
|
The discrete Fourier transform. O(n^2), since this library does not specialize in these operations. |
|
For an iterable with items |
Successive distinct permutations of the elements in |
|
|
Like |
|
Drop items from the iterable until the predicate called on the item holds. |
Like |
|
|
Async version of |
Like |
|
|
|
|
Yield every |
|
Yield every other item from an (async) iterable, optionally skipping the first item. |
|
Generate the prime factors of |
|
Async version of |
|
Async version of |
|
Return the first item in the (async) iterable |
|
Return the first item in the (async) iterable |
|
Return the first item in the (async) iterable |
|
Flatten one level of nesting using |
|
|
|
Yield |
|
Determine if the matrix product of |
|
Wrap |
|
Yield the given value, then return. |
|
Async version of |
Async version of |
|
|
|
|
Optimal solution to the secretary problem, using |
|
Like |
|
|
|
The inverse discrete Fourier transform. O(n^2) just like |
|
|
|
Return the length of the (async) iterable |
|
Interleave items of the iterables evenly according to the lengths if passed, and determined by calling the |
|
Interleave items of the iterables randomly, skipping exhausted iterables. |
|
Yield the items from the iterables in a round-robin fashion until at least one is exhausted. |
|
Feed |
|
Yield |
|
Return whether the (async) iterable |
|
Async version of |
|
Probabilistically test for primality of |
|
Yield the indices at which |
|
Yield |
|
Yield the awaited output of |
|
Return the last item in the (async) iterable |
|
|
|
|
|
Yield |
|
Async version of |
|
Essentially the restriction of |
|
Matrix multiplication of |
|
Return the product of the matrices in the (async) iterable, preceded by |
|
Async version of |
Async version of |
|
|
Async version of |
|
Return a tuple of the smallest item and the largest item in the iterable or among the positional arguments by making a single pass. If the iterable is empty, return |
Like |
|
|
|
Composition of |
|
|
Composition of |
Composition of |
|
Composition of |
|
Composition of |
|
|
Yield the items in the (async) iterable |
|
Return the |
|
Return the |
|
Return the |
|
Return the |
|
Return the |
|
Return the |
|
|
|
Yield the items in the (async) iterable |
|
Yield the items in the (async) iterable |
|
Async version of |
|
Return a tuple |
|
Async version of |
|
Compute the coefficients of the derivative of a polynomial. Both input and output iterables are in order of descending powers. |
|
Evaluate a polynomial at |
|
Generate the coefficients of a polynomial given its roots in order of descending powers. |
|
Yield |
|
Optimized version of |
|
Yield all the subsets of the (async) iterable |
Yield all the subsets of the items in the (async) iterable of hashable objects after consuming it at once and removing duplicates, as |
|
|
Prepend |
|
Return the product of the items in the (async) iterable, preceded by |
|
Async version of |
|
Return the number of items in the (async) iterable for which the predicate is true. |
|
Draw |
Draw |
|
|
Generate a random derangement of items in the (async) iterable |
|
Choose a random permutation of the elements in |
|
Draw |
|
Async version of |
|
Async version of |
|
Yield each item in the (async) iterable |
|
Call the async function |
|
Yield all the items in the (async) iterable |
|
Change the shape of a tensor according to |
|
Reverse an (async) iterable, calling its |
|
Yield items from the given (async) iterables in round-robin order, skipping exhausted iterables. Prefer over |
|
Yield items from the given (async) iterables in round-robin order, skipping exhausted iterables. Prefer over |
|
Inverse of the above, but takes any (async) iterable and always gives an async generator. |
|
Compress an (async) iterable into an async generator of pairs with run-length encoding. Items in the result are in the form |
|
Repeatedly yield the mean of the items in the iterable so far, and advance the iterable. |
|
Yield the median of all the items seen from |
|
Chooses |
|
Choose |
|
Return a list representing a random full-length permutation of the items in |
|
Feed |
|
Protect an (async) iterable from being consumed by many parties concurrently by applying an async lock. |
|
|
|
Yield prime numbers strictly smaller than |
|
|
|
Async version of |
|
Split an async iterator at each item satisfying |
|
Return an async generator containing the first |
|
Filter an (async) iterable of tuples of items, yielding only those tuples for which the predicate returns a truthy value when called on the tuple unpacked. |
Filter an (async) iterable of tuples of items, yielding only those tuples for which the predicate returns a falsy value when called on the tuple unpacked. |
|
|
Async version of |
|
Like |
|
|
Yield tuples of the form |
|
|
Yield all contiguous subsequences of the (async) iterable |
|
Return the sum of the items in the (async) iterable, preceded by |
|
Return the sum of squares of items in an (async) iterable of numbers as a number of the same type. |
|
Return the sum of products of items in two iterables of numbers as a number of the same type. Not as precise as |
|
|
|
|
|
Yield the last |
|
Take items from the iterable until the predicate called on the item holds. |
Like |
|
|
Async version of |
Like |
|
|
Compute the transpose of a matrix. |
|
Yield overlapping triples of items from an (async) iterable. |
|
Yield unique elements from |
Yield items from the (async) iterable |
|
Yield items from the (async) iterable |
|
|
Given multiple (async) iterables, yield every item that is only seen in exactly one of the iterables. |
|
|
|
Yield tuples of the form |
|
Wrap the (async) iterable |
|
Call |
|
Async version of |
|
|
|
Async version of |
|
Return a list of the first |
|
More flexible but slightly slower implementation of |
|
Batch an (async) iterable into an async generator of lists. If |
|
Apply |
|
|
|
|
|
Yield copies of the items in the (async) iterable |
|
|
|
|
|
|
|
|
|
|
|
|
|
Return an async generator that yields nothing. Due to async generator finalization issues, this is not a constant like |
|
|
|
|
|
|
|
Async version of |
|
Return a list of the results of calling each async function in the first argument (an (async) iterable of functions), with the provided arguments. |
|
Like |
|
Like |
|
|
|
|
|
Yield tuples of the form |
|
Return the Hamming distance between two (async) iterables, using |
|
|
|
|
|
Return a task that calls |
|
|
|
|
|
|
|
|
|
Apply a transformation on an (async) iterable on top of another. |
|
|
|
|
|
Multiplication of a matrix |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Collect all items in the (async) iterable |
|
Collect all items of an async iterable into a list. Faster than |
|
Collect all items in the (async) iterable |
|
Convert the output of |
|
Whether the vectors |
|
Window an async iterable into an async generator of tuples of the specified size and step. You can send in a tuple |
Module Contents¶
- class asyncutils.iters.FirstMisMatch[T, R]¶
Bases:
NamedTuple- lrem: types.AsyncGeneratorType[T]¶
- rrem: types.AsyncGeneratorType[R]¶
- asyncutils.iters.aaccumulate[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T, T], T] = ...,
- *,
- initial: T | None = ...,
Async version of
itertools.accumulate()that is not a class.
- asyncutils.iters.aadjacent[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- dist: int = ...,
- *,
- await_pred: Literal[False] = ...,
- asyncutils.iters.aadjacent(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- dist: int = ...,
- *,
- await_pred: Literal[True],
For each
itemin the (async) iterableit, yield tuples of the form(is_within_dist, item), whereis_within_distisTrueiff the closest distance to an item satisfyingpredis at mostdist, and the call topredis awaited iffawait_pred=Trueis passed.
- async asyncutils.iters.aall(it: asyncutils._internal.prots.SupportsIteration[object]) bool[source]¶
Async version of
all().
- async asyncutils.iters.aall_equal[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], object] = ...,
- strict: bool = ...,
Whether all items in the (async) iterable are equal to each other according to the
keyfunction. Check for identity rather than equality ifstrictisTrue.
- async asyncutils.iters.aall_unique[T](it: asyncutils._internal.prots.SupportsIteration[T], key: None = ...) bool[source]¶
- async asyncutils.iters.aall_unique(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.aall_unique(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- *,
- await_key: Literal[True],
Return whether all the items in the (async) iterable
itare distinct (according tokey, awaited ifawait_key=Trueis passed, if passed).
- async asyncutils.iters.aany(it: asyncutils._internal.prots.SupportsIteration[object]) bool[source]¶
Async version of
any().
- asyncutils.iters.aappend[T](val: T, it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Append
valto the (async) iterableit.
- async asyncutils.iters.aargmax[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: int = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.aargmax(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: int = ...,
- *,
- await_key: Literal[True],
- async asyncutils.iters.aargmax(it: asyncutils._internal.prots.SupportsIteration[T], *, default: int = ...) int
Return the index of the first occurrence of the maximum element in the (async) iterable
itaccording tokey, ordefaultif empty.
- async asyncutils.iters.aargmin[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: int = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.aargmin(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: int = ...,
- *,
- await_key: Literal[True],
- async asyncutils.iters.aargmin(it: asyncutils._internal.prots.SupportsIteration[T], *, default: int = ...) int
Return the index of the first occurrence of the minimum element in the (async) iterable
itaccording tokey, ordefaultif empty.
- async asyncutils.iters.aargminmax[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.aargminmax(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- *,
- await_key: Literal[True],
- async asyncutils.iters.aargminmax(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: R,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.aargminmax(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: R,
- *,
- await_key: Literal[True],
- async asyncutils.iters.aargminmax(it: asyncutils._internal.prots.SupportsIteration[T]) tuple[int, int]
- async asyncutils.iters.aargminmax(it: asyncutils._internal.prots.SupportsIteration[T], *, default: R) tuple[int, int] | R
Return a tuple of the indices of the first occurrences of the minimum and maximum elements in the (async) iterable
itaccording tokey, ordefaultif empty.
- asyncutils.iters.aawgenf2agenf[T, **P](
- f: collections.abc.Callable[P, collections.abc.AsyncIterable[T]],
- /,
Convert a function that returns an awaitable resolving to an async iterable into one returning an async generator.
- asyncutils.iters.abefore_and_after[T](
- pred: collections.abc.Callable[[T], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
atakewhile(), but return all remaining items in the second async generator (after the first is consumed).
- asyncutils.iters.abfs[T: collections.abc.Hashable](
- start: T,
- neighbours: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsIteration[T]],
- *,
- include_start: bool = ...,
Breadth-first search on a start node
start, given a functionneighboursthat returns an (async) iterable of neighbours to be traversed in order. Ifinclude_startisTrue, the start node is yielded first.
- async asyncutils.iters.abrent[T](next_node: collections.abc.Callable[[T], collections.abc.Awaitable[T]], start: T, /) tuple[T, int, int][source]¶
- Brent’s algorithm for cycle detection, assuming that a cycle is indeed present, given a function
next_nodereturning the next node from the previous.Return a tuple(node, la, mu), wherenodeis the first node involved in a cycle,muits index (the least number of timesnext_nodewas applied to getnode), andlathe cycle length.Note
next_nodeshould be deterministic. Also, if there is no cycle, the algorithm hangs indefinitely.
- asyncutils.iters.ac3merge[T]( ) types.AsyncGeneratorType[T][source]¶
Async version of
functools._c3_merge()that doesn’t assume the input is a synchronous iterable over mutable sequences of classes.
- asyncutils.iters.acanonical[T](it: asyncutils._internal.prots.SupportsIteration[T]) list[T][source]¶
Return a canonicalized ordering of the items in
it, which may change across different Python invocations or sessions.
- asyncutils.iters.acat[T](first: T) types.AsyncGeneratorType[T, T][source]¶
- asyncutils.iters.acat(first: None = ...) types.AsyncGeneratorType[T | None, T | None]
Yield the sent value, starting with
first(defaultNone).
- asyncutils.iters.acollapse(
- it: asyncutils._internal.prots.SupportsIteration[object],
- base_typ: tuple[type, Ellipsis] | type = ...,
- levels: int | None = ...,
Flatten the (async) iterable
itby at mostlevelslevels, without collapsing objects of types specified inbase_typ.
- asyncutils.iters.acombinations[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- r: int,
Async version of
itertools.combinations()that is not a class.
- asyncutils.iters.acombinations_with_replacement[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- r: int,
Async version of
itertools.combinations_with_replacement()that is not a class.
- asyncutils.iters.acompress[T](
- data: asyncutils._internal.prots.SupportsIteration[T],
- selectors: asyncutils._internal.prots.SupportsIteration[object],
Async version of
itertools.compress()that is not a class.
- async asyncutils.iters.aconsume[T](it: asyncutils._internal.prots.SupportsIteration[T], n: int | None = ...) None[source]¶
Advance the (async) iterable
itbynsteps, using a function-scoped executor created on demand where appropriate. If you want the item at the final position, useanth()instead.
- asyncutils.iters.aconvolve[T: (int, float, complex)](
- signal: asyncutils._internal.prots.SupportsIteration[T],
- kernel: asyncutils._internal.prots.SupportsIteration[T],
Polynomial multiplication with coefficients from the two iterables. The first iterable is advanced on demand, meaning it may be infinite, but the second iterable is exhausted immediately, storing all its items in memory.
- asyncutils.iters.acount(start: int = ..., step: int = ...) types.AsyncGeneratorType[int][source]¶
- asyncutils.iters.acount(start: float, step: int = ...) types.AsyncGeneratorType[float]
- asyncutils.iters.acount(start: float, step: float) types.AsyncGeneratorType[float]
- asyncutils.iters.acount(*, step: float) types.AsyncGeneratorType[float]
Async version of
itertools.count()that is not a class.
- asyncutils.iters.acount_cycle[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int | None = ...,
Yield tuples of the form
(n, item), whereitemcycles through the iterable, caching its items during the first cycle, andnis the number of times the iterable has been completely cycled prior to yieldingitem.
- asyncutils.iters.acountdown(n: int, step: int = ..., *, include_zero: bool = ...) types.AsyncGeneratorType[int][source]¶
Count down from
nto zero, excluding zero if it is to appear andinclude_zeroisFalse(the default), by a step size ofstep.
- asyncutils.iters.acycle[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Async version of
itertools.cycle()that is not a class.
- asyncutils.iters.aderangements[T](it: asyncutils._internal.prots.SupportsIteration[T], r: int | None = ...) types.AsyncGeneratorType[T][source]¶
Successive derangements of the elements in
itof sizer, or all sizes if not passed. Derangements are permutations with no fixed points.
- asyncutils.iters.adfs[T: collections.abc.Hashable](
- start: T,
- neighbours: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsIteration[T]],
- *,
- include_start: bool = ...,
Depth-first search on a start node
start, given a functionneighboursthat returns an (async) iterable of neighbours to be traversed in order. Ifinclude_startisTrue, the start node is yielded first.
- asyncutils.iters.adft(xarr: asyncutils._internal.prots.SupportsIteration[complex], /) types.AsyncGeneratorType[complex][source]¶
The discrete Fourier transform. O(n^2), since this library does not specialize in these operations.
- asyncutils.iters.adifference[T, R](
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T, T], R],
- *,
- yield_initial: Literal[False],
- await_func: Literal[False] = ...,
- asyncutils.iters.adifference(
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T, T], collections.abc.Awaitable[R]],
- *,
- yield_initial: Literal[False],
- await_func: Literal[True],
- asyncutils.iters.adifference(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- yield_initial: bool = ...,
- await_func: Literal[False] = ...,
- asyncutils.iters.adifference(
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T, T], collections.abc.Awaitable[T]],
- *,
- yield_initial: Literal[True] = ...,
- await_func: Literal[True],
For an iterable with items
a,b,c, etc., yielda,func(b, a),func(c, b), droppingaiffyield_initial=Falsewas passed and awaiting the return value iffawait_func=Truewas passed. Essentially the inverse ofaaccumulate().
- asyncutils.iters.adistinct_permutations[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- r: int | None = ...,
Successive distinct permutations of the elements in
itof sizer, or all sizes if not passed.
- asyncutils.iters.adouble_starmap[T](
- f: collections.abc.Callable[Ellipsis, T],
- it: asyncutils._internal.prots.SupportsIteration[collections.abc.Mapping[str, Any]],
- /,
Like
amap(), but the iterables should yield mappings that are unpacked as arguments to the function.
- asyncutils.iters.adropuntil[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[False] = ...,
- asyncutils.iters.adropuntil(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[True],
Drop items from the iterable until the predicate called on the item holds.
- asyncutils.iters.adropuntil_exclusive[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[False] = ...,
- asyncutils.iters.adropuntil_exclusive(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[True],
Like
adropuntil()but starts only after dropping the first truthy item.
- asyncutils.iters.adropwhile[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[False] = ...,
- asyncutils.iters.adropwhile(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[True],
Async version of
itertools.dropwhile()that is not a class.
- asyncutils.iters.adropwhile_exclusive[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[False] = ...,
- asyncutils.iters.adropwhile_exclusive(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[True],
Like
adropwhile()but starts only after dropping the first falsy item.
- async asyncutils.iters.advance_by(it: asyncutils._internal.prots.SupportsIteration[object], n: int) None[source]¶
- asyncutils.iters.aevery[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int,
- *,
- skip_first: bool = ...,
Yield every
n-th item from an (async) iterable, optionally skipping the first item.
- asyncutils.iters.aevery_other[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- skip_first: bool = ...,
Yield every other item from an (async) iterable, optionally skipping the first item.
- asyncutils.iters.afactor(n: int) types.AsyncGeneratorType[int][source]¶
Generate the prime factors of
nasynchronously. Do not rely on the resultant order.
- asyncutils.iters.afilter[T](
- f: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[False] = ...,
- asyncutils.iters.afilter(
- f: collections.abc.Callable[[T], collections.abc.Awaitable[object]] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[True],
Async version of
filterthat is not a class.
- asyncutils.iters.afilterfalse[T](
- f: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[False] = ...,
- asyncutils.iters.afilterfalse(
- f: collections.abc.Callable[[T], collections.abc.Awaitable[object]] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[True],
Async version of
itertools.filterfalse()that is not a class.
- async asyncutils.iters.afirst[T](it: asyncutils._internal.prots.SupportsIteration[T], default: T = ...) T[source]¶
Return the first item in the (async) iterable
it, ordefaultif passed anditis empty.
- async asyncutils.iters.afirstfalse[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T | None = ...,
- pred: collections.abc.Callable[[T], object] = ...,
Return the first item in the (async) iterable
itthat fails the predicate, ordefaultif passed and there is no such item, and raiseStopAsyncIterationotherwise.
- asyncutils.iters.afirstfalse_or_first[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- pred: collections.abc.Callable[[T], object] | None = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.afirstfalse_or_first(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T,
- pred: collections.abc.Callable[[T], object] | None = ...,
- *,
- await_pred: Literal[False] = ...,
- asyncutils.iters.afirstfalse_or_first(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_pred: Literal[True],
- asyncutils.iters.afirstfalse_or_first(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T,
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- *,
- await_pred: Literal[True],
- asyncutils.iters.afirstfalse_or_last[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- pred: collections.abc.Callable[[T], object] | None = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.afirstfalse_or_last(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T,
- pred: collections.abc.Callable[[T], object] | None = ...,
- *,
- await_pred: Literal[False] = ...,
- asyncutils.iters.afirstfalse_or_last(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_pred: Literal[True],
- asyncutils.iters.afirstfalse_or_last(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T,
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- *,
- await_pred: Literal[True],
- async asyncutils.iters.afirsttrue[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T | None = ...,
- pred: collections.abc.Callable[[T], object] = ...,
Return the first item in the (async) iterable
itthat satisfies the predicate, ordefaultif passed and there is no such item, and raiseStopAsyncIterationotherwise.
- asyncutils.iters.afirsttrue_or_first[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- pred: collections.abc.Callable[[T], object] | None = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.afirsttrue_or_first(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T,
- pred: collections.abc.Callable[[T], object] | None = ...,
- *,
- await_pred: Literal[False] = ...,
- asyncutils.iters.afirsttrue_or_first(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_pred: Literal[True],
- asyncutils.iters.afirsttrue_or_first(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T,
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- *,
- await_pred: Literal[True],
- asyncutils.iters.afirsttrue_or_last[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- pred: collections.abc.Callable[[T], object] | None = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.afirsttrue_or_last(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T,
- pred: collections.abc.Callable[[T], object] | None = ...,
- *,
- await_pred: Literal[False] = ...,
- asyncutils.iters.afirsttrue_or_last(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_pred: Literal[True],
- asyncutils.iters.afirsttrue_or_last(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T,
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- *,
- await_pred: Literal[True],
- asyncutils.iters.aflatten[T]( ) types.AsyncGeneratorType[T][source]¶
Flatten one level of nesting using
AChainand return an async iterator over it.
- asyncutils.iters.aflatten_tensor(
- tensor: asyncutils._internal.prots.SupportsIteration[object],
- base_typ: tuple[type, Ellipsis] | type = ...,
acollapse(), but using a different, more memory-efficient strategy that does not support thelevelsparameter.
- asyncutils.iters.aforever() types.AsyncGeneratorType[None][source]¶
Yield
Noneforever. Equivalent toarepeat(None).
- async asyncutils.iters.afreivalds(
- A: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[int]],
- B: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[int]],
- C: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[int]],
- k: int = ...,
Determine if the matrix product of
AandBequalsC. This is the probabilistic Freivalds algorithm. O(kn^2) time, with a false positive rate of at most 2^(-k) and no false negatives.
- async asyncutils.iters.agather[T](
- it_of_its: asyncutils._internal.prots.SupportsIteration[collections.abc.Awaitable[T]],
- return_exceptions: bool = ...,
Wrap
asyncio.gather()to accept (async) iterables as the first argument, so that unpacking is not needed.
- asyncutils.iters.agives[T](x: T, /) types.AsyncGeneratorType[T][source]¶
Yield the given value, then return.
- asyncutils.iters.agroupby[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], T] = ...,
- asyncutils.iters.agroupby(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], R],
Async version of
itertools.groupby()that is not a class.
- asyncutils.iters.agroupby_transform[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- vf: None = ...,
- rf: None = ...,
- await_kf: Literal[False] = ...,
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], R],
- vf: None = ...,
- rf: None = ...,
- *,
- await_kf: Literal[False] = ...,
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- vf: None = ...,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], S],
- await_kf: Literal[False] = ...,
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- vf: None = ...,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], collections.abc.Awaitable[S]],
- await_kf: Literal[False] = ...,
- await_vf: Literal[False] = ...,
- await_rf: Literal[True],
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], R],
- *,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], S],
- await_kf: Literal[False] = ...,
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], R],
- vf: None,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], S],
- *,
- await_kf: Literal[False] = ...,
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], R],
- *,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], collections.abc.Awaitable[S]],
- await_kf: Literal[False] = ...,
- await_vf: Literal[False] = ...,
- await_rf: Literal[True],
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], R],
- vf: None,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], collections.abc.Awaitable[S]],
- *,
- await_kf: Literal[False] = ...,
- await_vf: Literal[False] = ...,
- await_rf: Literal[True],
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: None = ...,
- rf: None = ...,
- *,
- await_kf: Literal[True],
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- *,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], S],
- await_kf: Literal[True],
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: None,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], S],
- *,
- await_kf: Literal[True],
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- *,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], collections.abc.Awaitable[S]],
- await_kf: Literal[True],
- await_vf: Literal[False] = ...,
- await_rf: Literal[True],
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: None,
- rf: collections.abc.Callable[[types.AsyncGeneratorType[T]], collections.abc.Awaitable[S]],
- *,
- await_kf: Literal[True],
- await_vf: Literal[False] = ...,
- await_rf: Literal[True],
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: collections.abc.Callable[[T], V],
- rf: None = ...,
- *,
- await_kf: Literal[True],
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: collections.abc.Callable[[T], V],
- rf: collections.abc.Callable[[types.AsyncGeneratorType[V]], S],
- *,
- await_kf: Literal[True],
- await_vf: Literal[False] = ...,
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: collections.abc.Callable[[T], V],
- rf: collections.abc.Callable[[types.AsyncGeneratorType[V]], collections.abc.Awaitable[S]],
- *,
- await_kf: Literal[True],
- await_vf: Literal[False] = ...,
- await_rf: Literal[True],
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: collections.abc.Callable[[T], collections.abc.Awaitable[V]],
- rf: None = ...,
- *,
- await_kf: Literal[True],
- await_vf: Literal[True],
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: collections.abc.Callable[[T], collections.abc.Awaitable[V]],
- rf: collections.abc.Callable[[types.AsyncGeneratorType[V]], S],
- *,
- await_kf: Literal[True],
- await_vf: Literal[True],
- await_rf: Literal[False] = ...,
- asyncutils.iters.agroupby_transform(
- it: asyncutils._internal.prots.SupportsIteration[T],
- kf: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- vf: collections.abc.Callable[[T], collections.abc.Awaitable[V]],
- rf: collections.abc.Callable[[types.AsyncGeneratorType[V]], collections.abc.Awaitable[S]],
- *,
- await_kf: Literal[True],
- await_vf: Literal[True],
- await_rf: Literal[True],
Async version of
more_itertools.groupby_transform().
- asyncutils.iters.agrouper[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int,
- fillvalue: T | asyncutils._internal.prots.Raise = ...,
- Collect items of the (async) iterable
itinto tuples of lengthneach.Otherwise, pad the last group withfillvalueto lengthnif needed. No padding is done if not passed.
- async asyncutils.iters.aguessmax[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- estlen: int | None = ...,
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison] = ...,
- default: T = ...,
- finish_event: asyncutils._internal.prots.EventProtocol | None = ...,
- reject_cb: None = ...,
- async asyncutils.iters.aguessmax(
- it: asyncutils._internal.prots.SupportsIteration[T],
- estlen: int | None = ...,
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison] = ...,
- default: T = ...,
- finish_event: asyncutils._internal.prots.EventProtocol | None = ...,
- reject_cb: collections.abc.Callable[[T], object],
- await_cb: Literal[False] = ...,
- async asyncutils.iters.aguessmax(
- it: asyncutils._internal.prots.SupportsIteration[T],
- estlen: int | None = ...,
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison] = ...,
- default: T = ...,
- finish_event: asyncutils._internal.prots.EventProtocol | None = ...,
- reject_cb: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_cb: Literal[True],
Optimal solution to the secretary problem, using
keyto guess the maximum item, which is the candidate chosen, with 36.8% accuracy, by finding the maximum among the first 36.8% of the (async) iterable and then returning the first item greater than that afterwards, in O(1) space.reject_cbis called on every rejected candidate once rejected, its return value awaited ifawait_cb=Trueis passed, and no more than one candidate is ever stored. This Numberphile video proves that the approach used is best.
- async asyncutils.iters.aguessmin[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- estlen: int | None = ...,
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison] = ...,
- default: T = ...,
- finish_event: asyncutils._internal.prots.EventProtocol | None = ...,
- reject_cb: None = ...,
- async asyncutils.iters.aguessmin(
- it: asyncutils._internal.prots.SupportsIteration[T],
- estlen: int | None = ...,
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison] = ...,
- default: T = ...,
- finish_event: asyncutils._internal.prots.EventProtocol | None = ...,
- reject_cb: collections.abc.Callable[[T], object],
- await_cb: Literal[False] = ...,
- async asyncutils.iters.aguessmin(
- it: asyncutils._internal.prots.SupportsIteration[T],
- estlen: int | None = ...,
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison] = ...,
- default: T = ...,
- finish_event: asyncutils._internal.prots.EventProtocol | None = ...,
- reject_cb: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_cb: Literal[True],
Like
aguessmax(), but guesses the minimum item instead.
- asyncutils.iters.aichunked[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int,
- asyncutils.iters.aidft(Xarr: asyncutils._internal.prots.SupportsIteration[complex], /) types.AsyncGeneratorType[complex][source]¶
The inverse discrete Fourier transform. O(n^2) just like
adft().
- async asyncutils.iters.aiequals(*its: asyncutils._internal.prots.SupportsIteration[object], strict: bool = ...) bool[source]¶
- async asyncutils.iters.ailen(it: asyncutils._internal.prots.SupportsIteration[object]) int[source]¶
Return the length of the (async) iterable
it, consuming it entirely.
- asyncutils.iters.ainterleave_evenly[T](
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- lengths: asyncutils._internal.prots.SupportsIteration[int] | None = ...,
Interleave items of the iterables evenly according to the lengths if passed, and determined by calling the
__len__()method on the iterables if present otherwise.
- asyncutils.iters.ainterleave_randomly[T]( ) types.AsyncGeneratorType[T][source]¶
Interleave items of the iterables randomly, skipping exhausted iterables.
- asyncutils.iters.ainterleave_stopearly[T](*it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Yield the items from the iterables in a round-robin fashion until at least one is exhausted.
- asyncutils.iters.aintersend[T, R](
- i1: collections.abc.AsyncGenerator[T, R],
- i2: collections.abc.AsyncGenerator[R, T],
Feed
i1andi2into each other and yield tuples of the form(yielded_from_i1, yielded_from_i2).
- asyncutils.iters.aintersperse[T](e: T, it: asyncutils._internal.prots.SupportsIteration[T], n: int = ...) types.AsyncGeneratorType[T][source]¶
Yield
e, then the nextnitems init, and repeat untilitis exhausted.
- async asyncutils.iters.aisempty(it: asyncutils._internal.prots.SupportsIteration[object]) bool[source]¶
Return whether the (async) iterable
itis empty.Note
This advances the iterable on success and discards the item. If the item is needed, call
afirst()instead and catchStopAsyncIterationor pass a default value.
- asyncutils.iters.aislice[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- stop: SupportsIndex | None = ...,
- /,
- asyncutils.iters.aislice(
- it: asyncutils._internal.prots.SupportsIteration[T],
- start: SupportsIndex | None,
- stop: SupportsIndex | None,
- step: SupportsIndex | None = ...,
- /,
Async version of
itertools.islice()that is not a class.
- async asyncutils.iters.aisprime(n: int) bool[source]¶
Probabilistically test for primality of
n. O(log^3 n), with false-positive rate below 2^(-128) for integers above 10^24.
- asyncutils.iters.aiter_idx[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- value: T,
- start: int = ...,
- stop: int | None = ...,
Yield the indices at which
valueoccurs initwithinstartandstop.
- asyncutils.iters.aiterate[T](f: collections.abc.Callable[[T], collections.abc.Awaitable[T]], start: T) types.AsyncGeneratorType[T][source]¶
Yield
start, then the awaited output offcalled on the previous output repeatedly.
- asyncutils.iters.aiterexcept[T](
- f: collections.abc.Callable[[], collections.abc.Awaitable[T]],
- exc: asyncutils._internal.prots.CanExcept,
- first: collections.abc.Callable[[], collections.abc.Awaitable[T]] = ...,
Yield the awaited output of
first, thenfcalled with no arguments repeatedly until an exception present inexcoccurs.
- async asyncutils.iters.alast[T](it: asyncutils._internal.prots.SupportsIteration[T], default: T = ...) T[source]¶
Return the last item in the (async) iterable
it, ordefaultif passed anditis empty.
- async asyncutils.iters.all_max[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: T = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.all_max(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: T = ...,
- *,
- await_key: Literal[True],
- async asyncutils.iters.all_max(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.all_min[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: T = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.all_min(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: T = ...,
- *,
- await_key: Literal[True],
- async asyncutils.iters.all_min(
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T = ...,
- *,
- await_key: Literal[False] = ...,
- asyncutils.iters.aloops(n: int) types.AsyncGeneratorType[None][source]¶
Yield
Nonentimes. Equivalent tobase.take(aforever(), n)andarepeat(None, n), but without creating intermediate integers.
- asyncutils.iters.amap[T, R](
- f: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_: Literal[True],
- strict: Literal[False] = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[T], R],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_: Literal[False] = ...,
- strict: Literal[False] = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[T, S], collections.abc.Awaitable[R]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_: Literal[True],
- strict: bool = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[T, S], R],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_: Literal[False] = ...,
- strict: bool = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[T, S, V], collections.abc.Awaitable[R]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_: Literal[True],
- strict: bool = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[T, S, V], R],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_: Literal[False] = ...,
- strict: bool = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[T, S, V, U], collections.abc.Awaitable[R]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_: Literal[True],
- strict: bool = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[T, S, V, U], R],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_: Literal[False] = ...,
- strict: bool = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[R]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[True],
- strict: bool = ...,
- asyncutils.iters.amap(
- f: collections.abc.Callable[[*tuple[T, ...]], R],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[False] = ...,
- strict: bool = ...,
Async version of
mapthat is not a class, withawait_dictating whether the return value of the function is to be awaited before yielding.
- asyncutils.iters.amapif[T, R](
- f: collections.abc.Callable[[T], R],
- p: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amapif(
- f: collections.abc.Callable[[T], R],
- p: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_transform: Literal[False],
- await_pred: Literal[True],
- asyncutils.iters.amapif(
- f: collections.abc.Callable[[T], R],
- p: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- await_pred: Literal[True],
- asyncutils.iters.amapif(
- f: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- p: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amapif(
- f: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- p: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_transform: Literal[True],
- await_pred: Literal[True],
Essentially the restriction of
amultimapif()to one (async) iterable.
- asyncutils.iters.amatmul[T: (int, float, complex)](
- M: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- N: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
Matrix multiplication of
MandN. O(n^3) time, since this library does not specialize in these operations.
- async asyncutils.iters.amatprod[T: asyncutils._internal.prots.SupportsMatMul](it: asyncutils._internal.prots.SupportsIteration[T], start: T) T[source]¶
Return the product of the matrices in the (async) iterable, preceded by
startif passed.
- async asyncutils.iters.amax[T: asyncutils._internal.prots.SupportsRichComparison](it: asyncutils._internal.prots.SupportsIteration[T], *, default: T = ...) T[source]¶
- async asyncutils.iters.amax(arg1: T, arg2: T, /, *args: T, default: T = ...) T
- async asyncutils.iters.amax(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: T = ...,
- await_key: Literal[False] = ...,
- async asyncutils.iters.amax(
- arg1: T,
- arg2: T,
- /,
- *args: T,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: T = ...,
- await_key: Literal[False] = ...,
- async asyncutils.iters.amax(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: T = ...,
- await_key: Literal[True],
- async asyncutils.iters.amax(
- arg1: T,
- arg2: T,
- /,
- *args: T,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: T = ...,
- await_key: Literal[True],
Async version of
max().
- asyncutils.iters.amerge_sorted_by[T: asyncutils._internal.prots.SupportsRichComparison](
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- *,
- key: collections.abc.Callable[[T], T] = ...,
- await_: Literal[False] = ...,
- reverse: bool = ...,
- asyncutils.iters.amerge_sorted_by(
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- await_: Literal[False] = ...,
- reverse: bool = ...,
- asyncutils.iters.amerge_sorted_by(
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- *,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- await_: Literal[True],
- reverse: bool = ...,
Async version of
heapq.merge().
- async asyncutils.iters.amin[T: asyncutils._internal.prots.SupportsRichComparison](it: asyncutils._internal.prots.SupportsIteration[T], *, default: T = ...) T[source]¶
- async asyncutils.iters.amin(arg1: T, arg2: T, /, *args: T, default: T = ...) T
- async asyncutils.iters.amin(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: T = ...,
- await_key: Literal[False] = ...,
- async asyncutils.iters.amin(
- arg1: T,
- arg2: T,
- /,
- *args: T,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- default: T = ...,
- await_key: Literal[False] = ...,
- async asyncutils.iters.amin(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: T = ...,
- await_key: Literal[True],
- async asyncutils.iters.amin(
- arg1: T,
- arg2: T,
- /,
- *args: T,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- default: T = ...,
- await_key: Literal[True],
Async version of
min().
- async asyncutils.iters.aminmax[R](*, default: R) R[source]¶
- async asyncutils.iters.aminmax(it: asyncutils._internal.prots.SupportsIteration[T], /) tuple[T, T]
- async asyncutils.iters.aminmax(it: asyncutils._internal.prots.SupportsIteration[T], /, *, default: R) tuple[T, T] | R
- async asyncutils.iters.aminmax(a: T, b: T, /, *items: T) tuple[T, T]
- async asyncutils.iters.aminmax(a: T, b: T, /, *items: T, default: R) tuple[T, T] | R
Return a tuple of the smallest item and the largest item in the iterable or among the positional arguments by making a single pass. If the iterable is empty, return
default. O(1) space and O(n) time.
- async asyncutils.iters.aminmax_keyed[R](*, key: collections.abc.Callable[[Any], object], default: R) R[source]¶
- async asyncutils.iters.aminmax_keyed(
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- await_key: Literal[False] = ...,
- async asyncutils.iters.aminmax_keyed(
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- await_key: Literal[False] = ...,
- default: R,
- async asyncutils.iters.aminmax_keyed(
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- await_key: Literal[True],
- async asyncutils.iters.aminmax_keyed(
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- await_key: Literal[True],
- default: R,
- async asyncutils.iters.aminmax_keyed(
- a: T,
- b: T,
- /,
- *items: T,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- await_key: Literal[False] = ...,
- async asyncutils.iters.aminmax_keyed(
- a: T,
- b: T,
- /,
- *items: T,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- await_key: Literal[False] = ...,
- default: R,
- async asyncutils.iters.aminmax_keyed(
- a: T,
- b: T,
- /,
- *items: T,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- await_key: Literal[True],
- async asyncutils.iters.aminmax_keyed(
- a: T,
- b: T,
- /,
- *items: T,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- await_key: Literal[True],
- default: R,
Like
aminmax(), but performs comparisons according to the return value ofkey.
- asyncutils.iters.amultifilter[T](
- pred: collections.abc.Callable[[tuple[T]], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, R]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, R, V]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, R, V, U]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, R, V, U, S]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, Ellipsis]], object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[Any, Ellipsis]], object],
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T]], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, R]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, R, V]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, R, V, U]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, R, V, U, S]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[T, Ellipsis]], collections.abc.Awaitable[object]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilter(
- pred: collections.abc.Callable[[tuple[Any, Ellipsis]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilterfalse[T](
- pred: collections.abc.Callable[[tuple[T]], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, R]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, R, V]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, R, V, U]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, R, V, U, S]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, Ellipsis]], object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[Any, Ellipsis]], object],
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T]], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, R]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, R, V]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, R, V, U]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, R, V, U, S]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[T, Ellipsis]], collections.abc.Awaitable[object]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultifilterfalse(
- pred: collections.abc.Callable[[tuple[Any, Ellipsis]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- strict: bool = ...,
- await_pred: Literal[True],
Composition of
afilterfalse()andazip().
- asyncutils.iters.amultimapif[T, R](
- f: collections.abc.Callable[[T], R],
- pred: collections.abc.Callable[[tuple[T]], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[T]], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V], R],
- pred: collections.abc.Callable[[tuple[T, V]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[T, V]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V, S], R],
- pred: collections.abc.Callable[[tuple[T, V, S]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V, S], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[T, V, S]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V, S, U], R],
- pred: collections.abc.Callable[[tuple[T, V, S, U]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V, S, U], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[T, V, S, U]], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[*Ts], R],
- pred: collections.abc.Callable[[tuple[*Ts]], object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[*Ts], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[*Ts]], object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T], R],
- pred: collections.abc.Callable[[tuple[T]], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[T]], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V], R],
- pred: collections.abc.Callable[[tuple[T, V]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[T, V]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V, S], R],
- pred: collections.abc.Callable[[tuple[T, V, S]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V, S], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[T, V, S]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V, S, U], R],
- pred: collections.abc.Callable[[tuple[T, V, S, U]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[T, V, S, U], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[T, V, S, U]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[*Ts], R],
- pred: collections.abc.Callable[[tuple[*Ts]], collections.abc.Awaitable[object]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultimapif(
- f: collections.abc.Callable[[*Ts], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[tuple[*Ts]], collections.abc.Awaitable[object]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- await_transform: Literal[True],
- await_pred: Literal[True],
Composition of
astarmap(),afilter()andazip().
- asyncutils.iters.amultistarfilter[T](
- pred: collections.abc.Callable[[T], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T, R], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T, R, V], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T, R, V, U], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T, R, V, U, S], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[*tuple[T, ...]], object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[*tuple[Any, ...]], object],
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T, R], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T, R, V], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T, R, V, U], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[T, R, V, U, S], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[object]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilter(
- pred: collections.abc.Callable[[*tuple[Any, ...]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- strict: bool = ...,
- await_pred: Literal[True],
Composition of
astarfilter()andazip().
- asyncutils.iters.amultistarfilterfalse[T](
- pred: collections.abc.Callable[[T], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T, R], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T, R, V], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T, R, V, U], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T, R, V, U, S], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[*tuple[T, ...]], object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[*tuple[Any, ...]], object],
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- strict: bool = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T, R], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T, R, V], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T, R, V, U], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[T, R, V, U, S], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[object]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarfilterfalse(
- pred: collections.abc.Callable[[*tuple[Any, ...]], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- strict: bool = ...,
- await_pred: Literal[True],
Composition of
astarfilterfalse()andazip().
- asyncutils.iters.amultistarmapif[T, R](
- f: collections.abc.Callable[[T], R],
- pred: collections.abc.Callable[[T], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[T], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V], R],
- pred: collections.abc.Callable[[T, V], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[T, V], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V, S], R],
- pred: collections.abc.Callable[[T, V, S], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V, S], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[T, V, S], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V, S, U], R],
- pred: collections.abc.Callable[[T, V, S, U], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V, S, U], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[T, V, S, U], object],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[*Ts], R],
- pred: collections.abc.Callable[[*Ts], object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- await_transform: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[*Ts], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[*Ts], object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- await_transform: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T], R],
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V], R],
- pred: collections.abc.Callable[[T, V], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[T, V], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V, S], R],
- pred: collections.abc.Callable[[T, V, S], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V, S], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[T, V, S], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V, S, U], R],
- pred: collections.abc.Callable[[T, V, S, U], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[T, V, S, U], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[T, V, S, U], collections.abc.Awaitable[object]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[V],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_transform: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[*Ts], R],
- pred: collections.abc.Callable[[*Ts], collections.abc.Awaitable[object]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- await_transform: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.amultistarmapif(
- f: collections.abc.Callable[[*Ts], collections.abc.Awaitable[R]],
- pred: collections.abc.Callable[[*Ts], collections.abc.Awaitable[object]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- await_transform: Literal[True],
- await_pred: Literal[True],
Composition of
astarmap()andamultistarfilter().
- asyncutils.iters.ancycles[T](it: asyncutils._internal.prots.SupportsIteration[T], n: int) types.AsyncGeneratorType[T][source]¶
Yield the items in the (async) iterable
itover and over for a total ofncycles.
- async asyncutils.iters.anth[T](it: asyncutils._internal.prots.SupportsIteration[T], n: int, default: T = ...) T[source]¶
Return the
n-th item of the (async) iterableit, ordefaultif passed and there is no such item.
- asyncutils.iters.anth_combination[T](it: asyncutils._internal.prots.SupportsIteration[T], r: int, n: int) types.AsyncGeneratorType[T][source]¶
Return the
n-th combination ofrelements from the input iterableit, in lexicographic order.
- async asyncutils.iters.anth_combination_with_replacement[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- r: int,
- n: int,
Return the
n-th combination ofrelements from the input iterableit, in lexicographic order, allowing individual elements to be repeated.
- async asyncutils.iters.anth_or_last[T](it: asyncutils._internal.prots.SupportsIteration[T], n: int, default: T = ...) T[source]¶
Return the
n-th item in the (async) iterableit, or the last item if out of bounds, ordefaultif passed anditis empty.
- async asyncutils.iters.anth_permutation[T](it: asyncutils._internal.prots.SupportsIteration[T], r: int, n: int) tuple[T, Ellipsis][source]¶
Return the
n-th permutation ofrelements from the input iterableit, in lexicographic order.
- async asyncutils.iters.anth_product[T](n: int, *its: asyncutils._internal.prots.SupportsIteration[T], repeat: int = ...) tuple[T, Ellipsis][source]¶
Return the
n-th item of the Cartesian product of the input iterablesits, in lexicographic order, with each iterable repeatedrepeattimes.
- asyncutils.iters.aonline_sorter[T: asyncutils._internal.prots.NotNone](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- reverse: bool = ...,
- *,
- await_key: Literal[False] = ...,
- asyncutils.iters.aonline_sorter(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: None = ...,
- reverse: bool = ...,
- *,
- await_key: Literal[False] = ...,
- asyncutils.iters.aonline_sorter(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- reverse: bool = ...,
- *,
- await_key: Literal[True],
- Sort items from an (async) iterable and those sent in on the fly in the async generator interface (i.e. by awaiting the return value of
asend).IfreverseisTrue, emit items in descending order.The return value ofkeyis awaited iffawait_key=Trueis passed. IfkeyisNone(the default), the items themselves are compared.Items cannot beNone, because for an async generatoragen,agen.asend(None)andanext(agen)are indistinguishable.Ifitis empty, the generator will also be empty.Note
Uses a heap internally, which is O(log n) time per item. Requires O(n) preprocessing time and O(n) auxiliary space.
Note
This function will instantiate and subsequently reuse an executor if there are 131072 initial items or more.
- asyncutils.iters.aouter_product[T, R, V, **P](
- f: collections.abc.Callable[Concatenate[T, R, P], collections.abc.Awaitable[V]],
- xs: asyncutils._internal.prots.SupportsIteration[T],
- ys: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *a: P,
- **k: P,
- asyncutils.iters.apadded[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- fillvalue: T,
- n: int | None = ...,
Yield the items in the (async) iterable
it, followed byfillvaluerepeatedly, such that the iterable is fully consumed and the result has length at leastnif passed.
- asyncutils.iters.apadnone[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int | None = ...,
Yield the items in the (async) iterable
it, followed byNonerepeatedly, such that the iterable is fully consumed and the result has length at leastnif passed.
- asyncutils.iters.apairwise[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[tuple[T, T]][source]¶
Async version of
itertools.pairwise()that is not a class.
- asyncutils.iters.apartition[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
Return a tuple
(fg, tg).tgis an async generator yielding the items initpassing the predicate, andfgthe others.
- asyncutils.iters.apermutations[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- r: int | None = ...,
Async version of
itertools.permutations()that is not a class.
- asyncutils.iters.apolynomial_derivative[T: (int, float, complex)](coeff: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Compute the coefficients of the derivative of a polynomial. Both input and output iterables are in order of descending powers.
- async asyncutils.iters.apolynomial_eval[T: (int, float, complex)](coeff: asyncutils._internal.prots.SupportsIteration[T], x: T) T[source]¶
Evaluate a polynomial at
xgiven its coefficients in order of descending powers.
- asyncutils.iters.apolynomial_from_roots[T: (int, float, complex)](roots: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Generate the coefficients of a polynomial given its roots in order of descending powers.
- asyncutils.iters.apowers[T: (int, float, complex)](base: T, start: T = ...) types.AsyncGeneratorType[T][source]¶
Yield
start,start*base,start*base*base, …Note
When it is found that the base is a perfect power of two, this will delegate to
apowers_of_two()as an optimization.
- asyncutils.iters.apowers_of_two(*, init: int = ..., init_shift: int = ..., shift: int = ...) types.AsyncGeneratorType[int][source]¶
Optimized version of
apowers()using bit shift operations for powers of two, four, eight, etc. Yieldinit<<init_shift,init<<init_shift+shift,init<<init_shift+2*shift, …
- asyncutils.iters.apowerset[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]¶
Yield all the subsets of the (async) iterable
it(by index!) as tuples, starting with the empty tuple.
- asyncutils.iters.apowerset_of_sets[T: collections.abc.Hashable](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- frozen: Literal[True] = ...,
- asyncutils.iters.apowerset_of_sets(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- frozen: Literal[False],
Yield all the subsets of the items in the (async) iterable of hashable objects after consuming it at once and removing duplicates, as
frozenset’s iffrozenisTrue(the default) andset’s otherwise.
- asyncutils.iters.aprepend[T](val: T, it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Prepend
valto the (async) iterableit.
- async asyncutils.iters.aprod[T: (int, float, complex)](it: asyncutils._internal.prots.SupportsIteration[T], start: T = ...) T[source]¶
Return the product of the items in the (async) iterable, preceded by
startif passed.
- asyncutils.iters.aproduct[T](
- i1: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- repeat: int,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- repeat: int,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- repeat: int,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- repeat: int,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- repeat: int,
- asyncutils.iters.aproduct(
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- repeat: int = ...,
- asyncutils.iters.aproduct(
- *its: asyncutils._internal.prots.SupportsIteration[T],
- repeat: int = ...,
Async version of
itertools.product()that is not a class.
- async asyncutils.iters.aquantify[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], object] = ...,
Return the number of items in the (async) iterable for which the predicate is true.
- asyncutils.iters.arandom_combination[T](it: asyncutils._internal.prots.SupportsIteration[T], r: int) types.AsyncGeneratorType[T][source]¶
Draw
ritems at random from the input iterableit, without replacement.
- asyncutils.iters.arandom_combination_with_replacement[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- r: int,
Draw
ritems at random from the input iterableit, with replacement.
- async asyncutils.iters.arandom_derangement[T](it: asyncutils._internal.prots.SupportsIteration[T]) tuple[T, Ellipsis][source]¶
Generate a random derangement of items in the (async) iterable
it.
- asyncutils.iters.arandom_permutation[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- r: int | None = ...,
Choose a random permutation of the elements in
itof sizer, or all sizes if not passed.
- asyncutils.iters.arandom_product[T](*its: asyncutils._internal.prots.SupportsIteration[T], n: int = ...) types.AsyncGeneratorType[T][source]¶
Draw
nitems from each of the input iterablesitsat random.
- asyncutils.iters.arange(stop: int, /) types.AsyncGeneratorType[int][source]¶
- asyncutils.iters.arange(start: int, stop: int, step: int = ..., /) types.AsyncGeneratorType[int]
Async version of
rangethat is not a class.
- asyncutils.iters.arepeat[T](elem: T, n: int = ...) types.AsyncGeneratorType[T][source]¶
Async version of
itertools.repeat()that is not a class.
- asyncutils.iters.arepeat_each[T](it: asyncutils._internal.prots.SupportsIteration[T], n: int) types.AsyncGeneratorType[T][source]¶
Yield each item in the (async) iterable
itexactlyntimes before advancing.
- asyncutils.iters.arepeat_func[T, *Ts](
- f: collections.abc.Callable[[*Ts], collections.abc.Awaitable[T]],
- times: int | None = ...,
- *a: *Ts,
Call the async function
fwith argumentsarepeatedly fortimestimes, or indefinitely iftimesis not passed, and yield the results awaited.
- asyncutils.iters.arepeat_last[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- default: T | asyncutils._internal.prots.Raise = ...,
Yield all the items in the (async) iterable
it, then keep yielding the last item forever, ordefaultif the iterable was empty, stopping if it was not passed. IfdefaultwasRAISE, raiseItemsExhausted.
- asyncutils.iters.areshape[T](
- mat: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- shape: int,
- asyncutils.iters.areshape(
- mat: asyncutils._internal.prots.SupportsIteration[object],
- shape: asyncutils._internal.prots.SupportsIteration[int],
Change the shape of a tensor according to
shape. For an integershape, the matrix must be 2D andshapeis the number of output columns.
- asyncutils.iters.areversed[T]( ) types.AsyncGeneratorType[T][source]¶
Reverse an (async) iterable, calling its
__reversed__()method and converting the result into an async generator if present, and fall back to consuming and saving all the items and yielding them in reverse order.
- asyncutils.iters.aroundrobin[T](*its: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Yield items from the given (async) iterables in round-robin order, skipping exhausted iterables. Prefer over
aroundrobin2()for less iterables.
- asyncutils.iters.aroundrobin2[T](*its: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Yield items from the given (async) iterables in round-robin order, skipping exhausted iterables. Prefer over
aroundrobin()for more iterables.
- asyncutils.iters.arunlength_decode[T](it: asyncutils._internal.prots.SupportsIteration[tuple[T, int]], /) types.AsyncGeneratorType[T][source]¶
Inverse of the above, but takes any (async) iterable and always gives an async generator.
- asyncutils.iters.arunlength_encode[T](it: asyncutils._internal.prots.SupportsIteration[T], /) types.AsyncGeneratorType[tuple[T, int]][source]¶
Compress an (async) iterable into an async generator of pairs with run-length encoding. Items in the result are in the form
(item, count), whereitemis an item from the input iterable andcountis the number of times it is repeated consecutively.
- asyncutils.iters.arunning_mean[T: (int, float, complex)](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Repeatedly yield the mean of the items in the iterable so far, and advance the iterable.
- asyncutils.iters.arunning_median[T: (int, float)](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- maxlen: SupportsIndex | None = ...,
Yield the median of all the items seen from
itwithin a window of sizemaxlen, then advance it.
- async asyncutils.iters.asample_l[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- k: int,
- *,
- rrange: collections.abc.Callable[[int], int] = ...,
- rand: collections.abc.Callable[[], float] = ...,
Chooses
kitems from an (async) iterable of items, where each item is chosen with equal probability.rrangeandrandshould be therandrange()andrandom()methods of a random device respectively. This is Algorithm L.
- async asyncutils.iters.asample_weighted[T](
- it: asyncutils._internal.prots.SupportsIteration[tuple[T, float]],
- k: int,
- *,
- rrange: collections.abc.Callable[[int], int] = ...,
- rand: collections.abc.Callable[[], float] = ...,
Choose
kitems from an (async) iterable of(item, weight)pairs, where the probability of each item being chosen is proportional to its weight.rrangeandrandshould be therandrange()andrandom()methods of a random device respectively. This is the A-Chao with Jumps reservoir sampling algorithm.
- async asyncutils.iters.asattolo[T](it: asyncutils._internal.prots.SupportsIteration[T], /) list[T][source]¶
Return a list representing a random full-length permutation of the items in
it.
- asyncutils.iters.asendstream[T, R](
- i1: collections.abc.AsyncGenerator[T, R],
- i2: asyncutils._internal.prots.SupportsIteration[R],
Feed
i2intoi1and yield the results.
- asyncutils.iters.aserialize[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Protect an (async) iterable from being consumed by many parties concurrently by applying an async lock.
- asyncutils.iters.aside_effect[T](
- f: collections.abc.Callable[[list[T]], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- size: int,
- before: collections.abc.Callable[[], object] | None = ...,
- after: collections.abc.Callable[[], object] | None = ...,
- asyncutils.iters.aside_effect(
- f: collections.abc.Callable[[T], object],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- size: None = ...,
- before: collections.abc.Callable[[], object] | None = ...,
- after: collections.abc.Callable[[], object] | None = ...,
- Apply a side effect function
fto each item in an (async) iterableitand yield the items unchanged in an async generator.Ifsizeis specified, the side effect function is applied to batches of that size instead of individual items, but the items are still yielded separately.Thebeforeandafterfunctions are called before and after the iteration, respectively, butafteris not called ifbeforefails.
- asyncutils.iters.asieve(n: int) types.AsyncGeneratorType[int][source]¶
Yield prime numbers strictly smaller than
nin order in an async generator.
- asyncutils.iters.asliced[T: asyncutils._internal.prots.SupportsSlicing[Any]](seq: T, n: int, strict: bool = ...) types.AsyncGeneratorType[T][source]¶
- Slice a sliceable object
seq(so named because these are usually sequences) and yield slices of the sizen, which should be of the same type asseq, from the start to the end.IfstrictisTrue, raiseValueErrorif the length of any slice is less thann(should only happen for the last slice unless the__getitem__()method is implemented incorrectly).
- asyncutils.iters.asorted[T: asyncutils._internal.prots.SupportsRichComparison](it: asyncutils._internal.prots.SupportsIteration[T], *, reverse: bool = ...) list[T][source]¶
- asyncutils.iters.asorted(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- reverse: bool = ...,
- await_key: Literal[False] = ...,
- asyncutils.iters.asorted(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- reverse: bool = ...,
- await_key: Literal[True],
Async version of
sorted(). O(n log n) time and O(n) space, but nowhere near as optimized as the builtin version.
- asyncutils.iters.asplitat[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], object],
- maxsplit: int = ...,
- keep_sep: bool = ...,
Split an async iterator at each item satisfying
pred, withkeep_sepdictating whether the separator is to be included as the last item of each list.
- asyncutils.iters.aspy[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int = ...,
Return an async generator containing the first
nitems, and another containing all the original items.
- asyncutils.iters.astarfilter[T](
- pred: collections.abc.Callable[[*tuple[T, ...]], object],
- it: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- await_pred: Literal[False] = ...,
- asyncutils.iters.astarfilter(
- pred: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- await_pred: Literal[True],
Filter an (async) iterable of tuples of items, yielding only those tuples for which the predicate returns a truthy value when called on the tuple unpacked.
- asyncutils.iters.astarfilterfalse[T](
- pred: collections.abc.Callable[[*tuple[T, ...]], object],
- it: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- await_pred: Literal[False] = ...,
- asyncutils.iters.astarfilterfalse(
- pred: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- await_pred: Literal[True],
Filter an (async) iterable of tuples of items, yielding only those tuples for which the predicate returns a falsy value when called on the tuple unpacked.
- asyncutils.iters.astarmap[*Ts, R](
- f: collections.abc.Callable[[*Ts], R],
- it: asyncutils._internal.prots.SupportsIteration[tuple[*Ts]],
- /,
- await_: Literal[False] = ...,
- asyncutils.iters.astarmap(
- f: collections.abc.Callable[[*Ts], collections.abc.Awaitable[R]],
- it: asyncutils._internal.prots.SupportsIteration[tuple[*Ts]],
- /,
- await_: Literal[True],
Async version of
itertools.starmap()that is not a class.await_specifies whether to await the return value of the transformation function.
- asyncutils.iters.astarmap_with_kwds[T](
- f: collections.abc.Callable[Ellipsis, T],
- it: asyncutils._internal.prots.SupportsIteration[tuple[collections.abc.Iterable[Any], collections.abc.Mapping[str, Any]]],
- /,
Like
amap(), but the iterable should yield tuples of the form(args, kwargs), whereargsis an iterable of positional arguments andkwargsis a mapping of keyword arguments.
- asyncutils.iters.asubslices[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]¶
asubstrings(), but yield all subslices containing the first item first in ascending order of length, then all subslices containing the second item but not the first, and so on.
- asyncutils.iters.asubstr_indices[S: (str, bytes, bytearray)](seq: S, reverse: bool = ...) types.AsyncGeneratorType[tuple[S, int, int]][source]¶
- asyncutils.iters.asubstr_indices(
- seq: asyncutils._internal.prots.SupportsSlicing[T],
- reverse: bool = ...,
Yield tuples of the form
(substr, start, end), wheresubstris a contiguous subsequence ofseqstarting at indexstartand ending at indexend-1(such that its length isend-start).
- asyncutils.iters.asubstrings[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]¶
Yield all contiguous subsequences of the (async) iterable
itas tuples, in increasing order of length.See also
asubslices()does the same in a different order.
- async asyncutils.iters.asum[T: (int, float, complex)](it: asyncutils._internal.prots.SupportsIteration[T], start: T = ...) T[source]¶
Return the sum of the items in the (async) iterable, preceded by
startif passed.
- async asyncutils.iters.asum_of_squares[T: (int, float, complex)](it: asyncutils._internal.prots.SupportsIteration[T]) T[source]¶
Return the sum of squares of items in an (async) iterable of numbers as a number of the same type.
- async asyncutils.iters.asumprod[T: (int, float, complex)](
- p: asyncutils._internal.prots.SupportsIteration[T],
- q: asyncutils._internal.prots.SupportsIteration[T],
- /,
Return the sum of products of items in two iterables of numbers as a number of the same type. Not as precise as
math.sumprod()for floating-point numbers, but supports async iterables.
- async asyncutils.iters.at_most_one[T](it: asyncutils._internal.prots.SupportsIteration[T], default: None = ...) T | None[source]¶
- async asyncutils.iters.at_most_one(it: asyncutils._internal.prots.SupportsIteration[T], default: R) T | R
- asyncutils.iters.atabulate[T](
- f: collections.abc.Callable[[int], T],
- start: int = ...,
- step: int = ...,
- /,
- *,
- await_: Literal[False],
- asyncutils.iters.atabulate(
- f: collections.abc.Callable[[int], collections.abc.Awaitable[T]],
- start: int = ...,
- step: int = ...,
- /,
- *,
- await_: Literal[True] = ...,
- asyncutils.iters.atabulate_finite[T](
- f: collections.abc.Callable[[int], collections.abc.Awaitable[T]],
- stop: int,
- /,
- *,
- await_: Literal[True] = ...,
- asyncutils.iters.atabulate_finite(
- f: collections.abc.Callable[[int], collections.abc.Awaitable[T]],
- start: int,
- stop: int,
- step: int = ...,
- /,
- *,
- await_: Literal[True] = ...,
- asyncutils.iters.atabulate_finite(
- f: collections.abc.Callable[[int], T],
- stop: int,
- /,
- *,
- await_: Literal[False],
- asyncutils.iters.atabulate_finite(
- f: collections.abc.Callable[[int], T],
- start: int,
- stop: int,
- step: int = ...,
- /,
- *,
- await_: Literal[False],
- asyncutils.iters.atail[T](n: int, it: asyncutils._internal.prots.SupportsIteration[T], /) types.AsyncGeneratorType[T][source]¶
Yield the last
nitems from the (async) iterableit.
- asyncutils.iters.atakeuntil[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[False] = ...,
- asyncutils.iters.atakeuntil(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[True],
Take items from the iterable until the predicate called on the item holds.
- asyncutils.iters.atakeuntil_inclusive[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[False] = ...,
- asyncutils.iters.atakeuntil_inclusive(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[True],
Like
atakewhile()but stops only after yielding the first truthy item.
- asyncutils.iters.atakewhile[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[False] = ...,
- asyncutils.iters.atakewhile(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[True],
Async version of
itertools.takewhile()that is not a class.
- asyncutils.iters.atakewhile_inclusive[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[False] = ...,
- asyncutils.iters.atakewhile_inclusive(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- await_pred: Literal[True],
Like
atakewhile()but stops only after yielding the first falsy item.
- asyncutils.iters.atranspose[T]( ) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]¶
Compute the transpose of a matrix.
- asyncutils.iters.atriplewise[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[tuple[T, T, T]][source]¶
Yield overlapping triples of items from an (async) iterable.
- asyncutils.iters.aunique[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison] | None = ...,
- reverse: bool = ...,
Yield unique elements from
itin sorted order, according tokey, which should not be too expensive. IfreverseisTrue, yield in descending order.
- asyncutils.iters.aunique_everseen[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
- asyncutils.iters.aunique_everseen(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_key: Literal[True],
- asyncutils.iters.aunique_everseen(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], object],
- await_key: Literal[False] = ...,
Yield items from the (async) iterable
it, without yielding items already previously yielded.
- asyncutils.iters.aunique_justseen[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
- asyncutils.iters.aunique_justseen(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_key: Literal[True],
- asyncutils.iters.aunique_justseen(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], object],
- await_key: Literal[False] = ...,
Yield items from the (async) iterable
it, without yielding consecutive duplicate items.
- asyncutils.iters.aunique_to_each[T: collections.abc.Hashable](*its: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Given multiple (async) iterables, yield every item that is only seen in exactly one of the iterables.
- async asyncutils.iters.aunzip[T](
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T]],
- *,
- put_batch: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R]],
- *,
- put_batch: int = ...,
- fillvalue: R,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T, S]],
- *,
- put_batch: int = ...,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R, S | R]],
- *,
- put_batch: int = ...,
- fillvalue: R,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T, S, V]],
- *,
- put_batch: int = ...,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R, S | R, V | R]],
- *,
- put_batch: int = ...,
- fillvalue: R,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T, S, V, U]],
- *,
- put_batch: int = ...,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R, S | R, V | R, U | R]],
- *,
- put_batch: int = ...,
- fillvalue: R,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T, Ellipsis]],
- *,
- put_batch: int = ...,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R, Ellipsis]],
- *,
- put_batch: int = ...,
- fillvalue: R,
- maxqsize: int = ...,
- async asyncutils.iters.aunzip(
- ait: asyncutils._internal.prots.SupportsIteration[tuple[Any, Ellipsis]],
- *,
- put_batch: int = ...,
- fillvalue: object = ...,
- maxqsize: int = ...,
- This function operates lazily, consuming items from the async iterable only when needed, in batches of size
put_batch(defaultAUNZIP_DEFAULT_PUT_BATCH) and caching other items in queues of capacitymaxqsize(defaultAUNZIP_DEFAULT_MAX_QSIZE).Warning
This function may require significant auxiliary space.
- asyncutils.iters.awindowed_complete[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int,
Yield tuples of the form
(prev, window, next), wherewindowis a tuple ofnitems from the (async) iterableit, andprevandnextare tuples of all the items before and after that window, respectively. Consumes and caches the whole iterable, so use with caution.
- asyncutils.iters.awrap[T](it: asyncutils._internal.prots.SupportsIteration[T], start: T, end: T) types.AsyncGeneratorType[T][source]¶
Wrap the (async) iterable
itby yieldingstartfirst, then the items init, thenend.
- asyncutils.iters.awrapf[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- before: collections.abc.Callable[[], object],
- after: None = ...,
- asyncutils.iters.awrapf(
- it: asyncutils._internal.prots.SupportsIteration[T],
- before: None,
- after: collections.abc.Callable[[], object],
- asyncutils.iters.awrapf(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- after: collections.abc.Callable[[], object],
- asyncutils.iters.awrapf(
- it: asyncutils._internal.prots.SupportsIteration[T],
- before: collections.abc.Callable[[], object],
- after: collections.abc.Callable[[], object],
Call
beforewhen the iterable starts, then yield the items init, then callafteras long asbeforedid not raise and the iterable was converted to an async generator successfully. The return value of each function is awaited if it doesn’t raiseTypeError.
- asyncutils.iters.azip[T](i1: asyncutils._internal.prots.SupportsIteration[T], /) types.AsyncGeneratorType[tuple[T]][source]¶
- asyncutils.iters.azip(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- asyncutils.iters.azip(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- strict: Literal[True],
- asyncutils.iters.azip(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- asyncutils.iters.azip(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- strict: Literal[True],
- asyncutils.iters.azip(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- asyncutils.iters.azip(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- strict: Literal[True],
- asyncutils.iters.azip(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- asyncutils.iters.azip(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- strict: Literal[True],
- asyncutils.iters.azip(
- *its: asyncutils._internal.prots.SupportsIteration[T],
- strict: bool = ...,
Async version of
zipthat is not a class.
- asyncutils.iters.azip_offset[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.azip_offset(
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: R,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: V,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: U,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: S,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[T],
- i3: asyncutils._internal.prots.SupportsIteration[T],
- i4: asyncutils._internal.prots.SupportsIteration[T],
- i5: asyncutils._internal.prots.SupportsIteration[T],
- i6: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.azip_offset(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[T],
- i3: asyncutils._internal.prots.SupportsIteration[T],
- i4: asyncutils._internal.prots.SupportsIteration[T],
- i5: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- longest: bool = ...,
- fillvalue: R,
- asyncutils.iters.aziplongest[T](i1: asyncutils._internal.prots.SupportsIteration[T], /) types.AsyncGeneratorType[tuple[T]][source]¶
- asyncutils.iters.aziplongest(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- fillvalue: object = ...,
- asyncutils.iters.aziplongest(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- fillvalue: object = ...,
- asyncutils.iters.aziplongest(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- fillvalue: object = ...,
- asyncutils.iters.aziplongest(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- fillvalue: object = ...,
- asyncutils.iters.aziplongest(
- *its: asyncutils._internal.prots.SupportsIteration[T],
- fillvalue: T = ...,
Async version of
itertools.zip_longest()that is not a class. The first overload does not acceptfillvalue, because passing it with only one iterable does not make sense.
- async asyncutils.iters.basic_collect[T](it: asyncutils._internal.prots.SupportsIteration[T], n: int = ...) list[T][source]¶
Return a list of the first
nitems in the (async) iterableit, signalling no error if there are not enough items.
- asyncutils.iters.batch[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int,
- *,
- item_timeout: float | None = ...,
- strict: bool = ...,
More flexible but slightly slower implementation of
batch2(), supporting timeouts waiting for each item, that raisesValueErrorinstead ofItemsExhaustedin the case of the length of the iterable being indivisible by the batch size.
- asyncutils.iters.batch2[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int,
- strict: Literal[True],
- asyncutils.iters.batch2(
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int | None,
- strict: Literal[False] = ...,
Batch an (async) iterable into an async generator of lists. If
strict=Trueis specified, raiseItemsExhaustedon the last batch if it is discovered then that the iterable does not have enough items for a complete batch.
- asyncutils.iters.batch_process[T, R](
- items: asyncutils._internal.prots.SupportsIteration[T],
- size: int,
- processor: collections.abc.Callable[[list[T]], collections.abc.Awaitable[R]],
Apply
processorto each batch of sizesizeinitemsand yield the results awaited.
- asyncutils.iters.buffer[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- maxsize: int = ...,
- *,
- timeout_get: float | None = ...,
- timeout_put: float | None = ...,
- cooldown: float = ...,
- Buffer the given (async) iterable in an async generator, with an async queue as buffer of capacity
maxsize(default unbounded) and optional timeouts for getting and putting items into the buffer.cooldownspecifies how long to wait after hitting a get timeout before trying again; whereas when a put timeout is reached, the async generator finishes.
- asyncutils.iters.circular_shifts[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- steps: int = ...,
- asyncutils.iters.cloned[T: asyncutils._internal.prots.SupportsCopy](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
Yield copies of the items in the (async) iterable
it, as returned bycopy().
- asyncutils.iters.coalesce[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- f: collections.abc.Callable[[T, T], T | asyncutils._internal.prots.NoCoalesce],
- await_: Literal[False] = ...,
- asyncutils.iters.coalesce(
- it: asyncutils._internal.prots.SupportsIteration[T],
- f: collections.abc.Callable[[T, T], collections.abc.Awaitable[T | asyncutils._internal.prots.NoCoalesce]],
- await_: Literal[True],
- asyncutils.iters.counts[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: None = ...,
- await_key: Literal[False] = ...,
- asyncutils.iters.counts(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: None = ...,
- await_key: Literal[False] = ...,
- asyncutils.iters.counts(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], R],
- await_key: Literal[False] = ...,
- asyncutils.iters.counts(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- await_key: Literal[True],
- asyncutils.iters.decreasing_runs[T: asyncutils._internal.prots.SupportsRichComparison](
- it: asyncutils._internal.prots.SupportsIteration[T],
- typ: type[T] | None = ...,
- max_runs: int = ...,
- async asyncutils.iters.diff_with[T, R](
- it1: asyncutils._internal.prots.SupportsIteration[T],
- it2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- cmpeq: collections.abc.Callable[[T, R], object] = ...,
- asyncutils.iters.distribute[T](n: Literal[1], it: asyncutils._internal.prots.SupportsIteration[T]) tuple[types.AsyncGeneratorType[T]][source]¶
- asyncutils.iters.distribute(
- n: Literal[2],
- it: asyncutils._internal.prots.SupportsIteration[T],
- asyncutils.iters.distribute(
- n: Literal[3],
- it: asyncutils._internal.prots.SupportsIteration[T],
- asyncutils.iters.distribute(
- n: Literal[4],
- it: asyncutils._internal.prots.SupportsIteration[T],
- asyncutils.iters.distribute(
- n: Literal[5],
- it: asyncutils._internal.prots.SupportsIteration[T],
- asyncutils.iters.distribute(n: int, it: asyncutils._internal.prots.SupportsIteration[T]) tuple[types.AsyncGeneratorType[T], Ellipsis]
- asyncutils.iters.duplicates[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: None = ...,
- *,
- await_key: Literal[False] = ...,
- asyncutils.iters.duplicates(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Hashable],
- *,
- await_key: Literal[False] = ...,
- asyncutils.iters.duplicates(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[collections.abc.Hashable]],
- *,
- await_key: Literal[True],
- asyncutils.iters.empty_agen() types.AsyncGeneratorType[Never][source]¶
Return an async generator that yields nothing. Due to async generator finalization issues, this is not a constant like
yield_to_event_loop.
- asyncutils.iters.extract[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- indices: asyncutils._internal.prots.SupportsIteration[SupportsIndex],
- fut: asyncio.Future[float] | None = ...,
- finish: bool = ...,
- Take an (async) iterable and an (async) iterable of integers interpreted as indices, and immediately returns a list of futures.Their eventual results represent the items of that iterable at the corresponding index.Also begin consumption of the iterable in the background.Exceptions will be set in the futures that are not done if results are encountered during iteration or if the index is out of bounds.Pass in a
Futurefor thefutparameter, which cancels the background consumption of the async iterable once it is done and cancels the undone futures.Attention
Negative indices would consume the whole iterable at once if not already consumed.
Warning
Do not set the result of any returned future; instead, if the result is no longer relevant, cancel the future.
Note
The consumption stops as soon as all the required results are pushed into the respective futures.
- asyncutils.iters.extract_monotonic[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- indices: asyncutils._internal.prots.SupportsIteration[SupportsIndex],
- asyncutils.iters.filter_identical[T](it: asyncutils._internal.prots.SupportsIteration[T], s: T) types.AsyncGeneratorType[T][source]¶
- asyncutils.iters.flat_map[T, R](
- f: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsIteration[R]]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_: Literal[True],
- strict: Literal[False] = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsIteration[R]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_: Literal[False] = ...,
- strict: Literal[False] = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[T, S], collections.abc.Awaitable[asyncutils._internal.prots.SupportsIteration[R]]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_: Literal[True],
- strict: bool = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[T, S], asyncutils._internal.prots.SupportsIteration[R]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_: Literal[False] = ...,
- strict: bool = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[T, S, V], collections.abc.Awaitable[asyncutils._internal.prots.SupportsIteration[R]]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_: Literal[True],
- strict: bool = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[T, S, V], asyncutils._internal.prots.SupportsIteration[R]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- await_: Literal[False] = ...,
- strict: bool = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[T, S, V, U], collections.abc.Awaitable[asyncutils._internal.prots.SupportsIteration[R]]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_: Literal[True],
- strict: bool = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[T, S, V, U], asyncutils._internal.prots.SupportsIteration[R]],
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[S],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_: Literal[False] = ...,
- strict: bool = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[asyncutils._internal.prots.SupportsIteration[R]]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[True],
- strict: bool = ...,
- asyncutils.iters.flat_map(
- f: collections.abc.Callable[[*tuple[T, ...]], asyncutils._internal.prots.SupportsIteration[R]],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[False] = ...,
- strict: bool = ...,
Async version of
mapthat is not a class, withawait_dictating whether the return value of the function is to be awaited before yielding.
- async asyncutils.iters.fmap[T, **P](
- fs: asyncutils._internal.prots.SupportsIteration[collections.abc.Callable[P, collections.abc.Awaitable[T]]],
- /,
- *a: P,
- **k: P,
Return a list of the results of calling each async function in the first argument (an (async) iterable of functions), with the provided arguments.
- asyncutils.iters.fmap_parallel[T, **P](
- fs: asyncutils._internal.prots.SupportsIteration[collections.abc.Callable[P, collections.abc.Awaitable[T]]],
- /,
- *a: P,
- **k: P,
Like
fmap_sequential(), but starts background tasks for each call.
- asyncutils.iters.fmap_sequential[T, **P](
- fs: asyncutils._internal.prots.SupportsIteration[collections.abc.Callable[P, collections.abc.Awaitable[T]]],
- /,
- *a: P,
- **k: P,
Like
fmap(), but only call a function after the last completes and the result is gotten.
- asyncutils.iters.fuse[T](
- it: asyncutils._internal.prots.SupportsIteration[T | None],
- end_at: None = ...,
- *,
- keep_end: bool = ...,
- asyncutils.iters.fuse(
- it: asyncutils._internal.prots.SupportsIteration[T | None],
- end_at: None = ...,
- *,
- keep_end: Literal[False] = ...,
- yield_after: R,
- asyncutils.iters.fuse(
- it: asyncutils._internal.prots.SupportsIteration[T | None],
- end_at: None = ...,
- *,
- keep_end: Literal[True],
- yield_after: R,
- asyncutils.iters.fuse(
- it: asyncutils._internal.prots.SupportsIteration[T | R],
- end_at: R,
- *,
- keep_end: bool = ...,
- asyncutils.iters.fuse(
- it: asyncutils._internal.prots.SupportsIteration[T | R],
- end_at: R,
- *,
- keep_end: Literal[False] = ...,
- yield_after: V,
- asyncutils.iters.fuse(
- it: asyncutils._internal.prots.SupportsIteration[T | R],
- end_at: R,
- *,
- keep_end: Literal[True],
- yield_after: V,
- asyncutils.iters.gray_product[T](
- i1: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- repeat: int,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- repeat: int,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- repeat: int,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- repeat: int,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- repeat: int,
- asyncutils.iters.gray_product(
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- repeat: int = ...,
- asyncutils.iters.gray_product(
- *its: asyncutils._internal.prots.SupportsIteration[T],
- repeat: int = ...,
- asyncutils.iters.group_from[T, R](
- keys: asyncutils._internal.prots.SupportsIteration[T],
- values: asyncutils._internal.prots.SupportsIteration[R],
- strict: bool = ...,
Yield tuples of the form
(key, group), wheregroupis an async generator taken fromvaluesand corresponding to the same run of keys inkeys. Ifstrict=Falseis passed, an error is not raised whenkeysandvaluesdiffer in length.
- async asyncutils.iters.hamming_dist[T](
- a: asyncutils._internal.prots.SupportsIteration[T],
- b: asyncutils._internal.prots.SupportsIteration[T],
- /,
- cmpeq: collections.abc.Callable[[T, T], object] = ...,
Return the Hamming distance between two (async) iterables, using
cmpeqto check for equality if passed.
- asyncutils.iters.increasing_runs[T: asyncutils._internal.prots.SupportsRichComparison](
- it: asyncutils._internal.prots.SupportsIteration[T],
- typ: type[T] | None = ...,
- max_runs: int = ...,
- async asyncutils.iters.is_sorted(
- it: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsRichComparison],
- key: None = ...,
- reverse: bool = ...,
- strict: bool = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.is_sorted(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsRichComparison],
- reverse: bool = ...,
- strict: bool = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.is_sorted(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- reverse: bool = ...,
- strict: bool = ...,
- *,
- await_key: Literal[True],
- asyncutils.iters.iter_task[T: asyncutils._internal.prots.SupportsIteration[object]](it: T, summaryf: collections.abc.Callable[[T], collections.abc.Awaitable[Any]] = ...) asyncio.Task[float][source]¶
Return a task that calls
summaryfon the passed (async) iterable and returns the time taken to run it. By default,summaryfconsumesitfully.
- asyncutils.iters.iterate_with_key[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: None = ...,
- await_key: Literal[False] = ...,
- asyncutils.iters.iterate_with_key(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], R],
- await_key: Literal[False] = ...,
- asyncutils.iters.iterate_with_key(
- it: asyncutils._internal.prots.SupportsIteration[T],
- key: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- await_key: Literal[True],
- asyncutils.iters.locate[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], object] = ...,
- window_size: None = ...,
- *,
- await_pred: Literal[False] = ...,
- asyncutils.iters.locate(
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- window_size: None = ...,
- *,
- await_pred: Literal[True],
- asyncutils.iters.locate(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- window_size: int,
- await_pred: Literal[False] = ...,
- asyncutils.iters.locate(
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], object],
- window_size: int,
- *,
- await_pred: Literal[False] = ...,
- asyncutils.iters.locate(
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[object]],
- window_size: int,
- *,
- await_pred: Literal[True],
- asyncutils.iters.longest_common_prefix[T](*its: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]¶
- asyncutils.iters.lstrip[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], object] | None = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.lstrip(
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_pred: Literal[True],
- asyncutils.iters.map_if_else[T](
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], T],
- func_else: None = ...,
- *,
- await_func: Literal[False] = ...,
- await_func_else: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], collections.abc.Awaitable[T]],
- func_else: None = ...,
- *,
- await_func: Literal[True],
- await_func_else: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], R],
- func_else: collections.abc.Callable[[T], R],
- *,
- await_func: Literal[False] = ...,
- await_func_else: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], R],
- func_else: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- *,
- await_func: Literal[False] = ...,
- await_func_else: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- func_else: collections.abc.Callable[[T], R],
- *,
- await_func: Literal[True],
- await_func_else: Literal[False] = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], object] | None,
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- func_else: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- *,
- await_func: Literal[True],
- await_func_else: Literal[True],
- await_pred: Literal[False] = ...,
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], T],
- func_else: None = ...,
- *,
- await_func: Literal[False] = ...,
- await_func_else: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], collections.abc.Awaitable[T]],
- func_else: None = ...,
- *,
- await_func: Literal[True],
- await_func_else: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], R],
- func_else: collections.abc.Callable[[T], R],
- *,
- await_func: Literal[False] = ...,
- await_func_else: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], R],
- func_else: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- *,
- await_func: Literal[False] = ...,
- await_func_else: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- func_else: collections.abc.Callable[[T], R],
- *,
- await_func: Literal[True],
- await_func_else: Literal[False] = ...,
- await_pred: Literal[True],
- asyncutils.iters.map_if_else(
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- func: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- func_else: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
- *,
- await_func: Literal[True],
- await_func_else: Literal[True],
- await_pred: Literal[True],
- asyncutils.iters.map_on_map[T, R, V](
- outer: collections.abc.Callable[[R], V],
- inner: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsIteration[R]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- inner_await: Literal[False] = ...,
- outer_await: Literal[False] = ...,
- asyncutils.iters.map_on_map(
- outer: collections.abc.Callable[[R], collections.abc.Awaitable[V]],
- inner: collections.abc.Callable[[T], asyncutils._internal.prots.SupportsIteration[R]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- inner_await: Literal[False] = ...,
- outer_await: Literal[True],
- asyncutils.iters.map_on_map(
- outer: collections.abc.Callable[[R], V],
- inner: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsIteration[R]]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- inner_await: Literal[True],
- outer_await: Literal[False] = ...,
- asyncutils.iters.map_on_map(
- outer: collections.abc.Callable[[R], collections.abc.Awaitable[V]],
- inner: collections.abc.Callable[[T], collections.abc.Awaitable[asyncutils._internal.prots.SupportsIteration[R]]],
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- inner_await: Literal[True],
- outer_await: Literal[True],
Apply a transformation on an (async) iterable on top of another.
- asyncutils.iters.map_windows[T, R](
- it: asyncutils._internal.prots.SupportsIteration[T],
- f: collections.abc.Callable[[*tuple[T, ...]], R],
- n: int,
- *,
- await_: Literal[False] = ...,
- star: Literal[True] = ...,
- asyncutils.iters.map_windows(
- it: asyncutils._internal.prots.SupportsIteration[T],
- f: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[R]],
- n: int,
- *,
- await_: Literal[True],
- star: Literal[True] = ...,
- asyncutils.iters.map_windows(
- it: asyncutils._internal.prots.SupportsIteration[T],
- f: collections.abc.Callable[[tuple[T, Ellipsis]], R],
- n: int,
- *,
- await_: Literal[False] = ...,
- star: Literal[False],
- asyncutils.iters.map_windows(
- it: asyncutils._internal.prots.SupportsIteration[T],
- f: collections.abc.Callable[[tuple[T, Ellipsis]], collections.abc.Awaitable[R]],
- n: int,
- *,
- await_: Literal[True],
- star: Literal[False],
- asyncutils.iters.mark_ends[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[tuple[bool, bool, T]][source]¶
- asyncutils.iters.mat_vec_mul(
- M: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[int]],
- V: asyncutils._internal.prots.SupportsIteration[int],
Multiplication of a matrix
Mand a vectorV. O(n^2).
- asyncutils.iters.merge[T](
- *I: asyncutils._internal.prots.SupportsIteration[T],
- reverse: bool = ...,
- maxqsize: int = ...,
- Merge items from the (async) iterables into a single async generator, according to the order in which they come.If
reverseisTrue, the order is reversed, but the returned generator only starts when all items are available.maxqsize(defaultMERGE_DEFAULT_MAX_QSIZE) controls the maximum number of items the consumer can fall behind the producers before the producers cease to be advanced.Caution
If
maxqsizeis smaller than the total number of items in the sources in reverse mode, a deadlock will occur.
- asyncutils.iters.pad_using[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- f: collections.abc.Callable[[int], collections.abc.Awaitable[T]],
- size: int | None = ...,
- *,
- await_: Literal[True] = ...,
- asyncutils.iters.pad_using(
- it: asyncutils._internal.prots.SupportsIteration[T],
- f: collections.abc.Callable[[int], T],
- size: int | None = ...,
- *,
- await_: Literal[False],
- asyncutils.iters.partial_product[T](
- i1: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- repeat: int,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- /,
- *,
- repeat: int,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- /,
- *,
- repeat: int,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- repeat: int,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- repeat: Literal[1] = ...,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[R],
- i3: asyncutils._internal.prots.SupportsIteration[V],
- i4: asyncutils._internal.prots.SupportsIteration[U],
- i5: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- repeat: int,
- asyncutils.iters.partial_product(
- i1: asyncutils._internal.prots.SupportsIteration[object],
- i2: asyncutils._internal.prots.SupportsIteration[object],
- i3: asyncutils._internal.prots.SupportsIteration[object],
- i4: asyncutils._internal.prots.SupportsIteration[object],
- i5: asyncutils._internal.prots.SupportsIteration[object],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[object],
- repeat: int = ...,
- asyncutils.iters.partial_product(
- *its: asyncutils._internal.prots.SupportsIteration[T],
- repeat: int = ...,
- asyncutils.iters.partitions[T](it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[list[tuple[T, Ellipsis]]][source]¶
- async asyncutils.iters.product_index[T](p: tuple[], repeat: int = ...) Literal[0][source]¶
- async asyncutils.iters.product_index(
- p: asyncutils._internal.prots.SupportsIteration[T],
- *its: asyncutils._internal.prots.SupportsIteration[T],
- repeat: int = ...,
- asyncutils.iters.rstrip[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], object] | None = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.rstrip(
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_pred: Literal[True],
- asyncutils.iters.scan[T, R, V](
- f: collections.abc.Callable[[collections.deque[R], T], V],
- s: R,
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_: Literal[False] = ...,
- asyncutils.iters.scan(
- f: collections.abc.Callable[[collections.deque[R], T], collections.abc.Awaitable[V]],
- s: R,
- it: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *,
- await_: Literal[True],
- asyncutils.iters.scan(
- f: collections.abc.Callable[[collections.deque[R], T, U], V],
- s: R,
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_: Literal[False] = ...,
- asyncutils.iters.scan(
- f: collections.abc.Callable[[collections.deque[R], T, U], collections.abc.Awaitable[V]],
- s: R,
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[U],
- /,
- *,
- await_: Literal[True],
- asyncutils.iters.scan(
- f: collections.abc.Callable[[collections.deque[R], T, U, S], V],
- s: R,
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[U],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_: Literal[False] = ...,
- asyncutils.iters.scan(
- f: collections.abc.Callable[[collections.deque[R], T, U, S], collections.abc.Awaitable[V]],
- s: R,
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[U],
- i3: asyncutils._internal.prots.SupportsIteration[S],
- /,
- *,
- await_: Literal[True],
- asyncutils.iters.scan(
- f: collections.abc.Callable[[collections.deque[R], T, T, T, T, *tuple[T, ...]], V],
- s: R,
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[T],
- i3: asyncutils._internal.prots.SupportsIteration[T],
- i4: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[False] = ...,
- asyncutils.iters.scan(
- f: collections.abc.Callable[[collections.deque[R], T, T, T, T, *tuple[T, ...]], collections.abc.Awaitable[V]],
- s: R,
- i1: asyncutils._internal.prots.SupportsIteration[T],
- i2: asyncutils._internal.prots.SupportsIteration[T],
- i3: asyncutils._internal.prots.SupportsIteration[T],
- i4: asyncutils._internal.prots.SupportsIteration[T],
- /,
- *its: asyncutils._internal.prots.SupportsIteration[T],
- await_: Literal[True],
- async asyncutils.iters.sort_together[T](
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- key_list: asyncutils._internal.prots.SupportsIteration[SupportsIndex] = ...,
- key: None = ...,
- reverse: bool = ...,
- strict: bool = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.sort_together(
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- *,
- key: collections.abc.Callable[Ellipsis, asyncutils._internal.prots.SupportsRichComparison],
- reverse: bool = ...,
- strict: bool = ...,
- await_key: Literal[False] = ...,
- async asyncutils.iters.sort_together(
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- key_list: asyncutils._internal.prots.SupportsIteration[SupportsIndex],
- key: collections.abc.Callable[Ellipsis, asyncutils._internal.prots.SupportsRichComparison],
- reverse: bool = ...,
- strict: bool = ...,
- *,
- await_key: Literal[False] = ...,
- async asyncutils.iters.sort_together(
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- *,
- key: collections.abc.Callable[Ellipsis, collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- reverse: bool = ...,
- strict: bool = ...,
- await_key: Literal[True],
- async asyncutils.iters.sort_together(
- its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
- key_list: asyncutils._internal.prots.SupportsIteration[SupportsIndex],
- key: collections.abc.Callable[Ellipsis, collections.abc.Awaitable[asyncutils._internal.prots.SupportsRichComparison]],
- reverse: bool = ...,
- strict: bool = ...,
- *,
- await_key: Literal[True],
- asyncutils.iters.split_when[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T, T], object],
- maxsplit: int = ...,
- asyncutils.iters.stagger[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- longest: Literal[False] = ...,
- fillvalue: None = ...,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- longest: Literal[False] = ...,
- fillvalue: R,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- longest: Literal[True],
- fillvalue: None = ...,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- *,
- longest: Literal[True],
- fillvalue: R,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: tuple[asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: tuple[asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: R,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: tuple[asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: tuple[asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: R,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: tuple[asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: tuple[asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: R,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: tuple[asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: tuple[asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: R,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: None = ...,
- asyncutils.iters.stagger(
- it: asyncutils._internal.prots.SupportsIteration[T],
- offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
- *,
- longest: bool = ...,
- fillvalue: R,
- asyncutils.iters.strip[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], object] | None = ...,
- await_pred: Literal[False] = ...,
- asyncutils.iters.strip(
- it: asyncutils._internal.prots.SupportsIteration[T],
- pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
- await_pred: Literal[True],
- asyncutils.iters.tee[T](it: asyncutils._internal.prots.SupportsIteration[T], n: Literal[1]) tuple[types.AsyncGeneratorType[T]][source]¶
- asyncutils.iters.tee(
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: Literal[2] = ...,
- *,
- maxqsize: int = ...,
- put_exc: bool = ...,
- loop: asyncio.AbstractEventLoop | None = ...,
- asyncutils.iters.tee(
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: Literal[3],
- *,
- maxqsize: int = ...,
- put_exc: bool = ...,
- loop: asyncio.AbstractEventLoop | None = ...,
- asyncutils.iters.tee(
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: Literal[4],
- *,
- maxqsize: int = ...,
- put_exc: bool = ...,
- loop: asyncio.AbstractEventLoop | None = ...,
- asyncutils.iters.tee(
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: Literal[5],
- *,
- maxqsize: int = ...,
- put_exc: bool = ...,
- loop: asyncio.AbstractEventLoop | None = ...,
- asyncutils.iters.tee(
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: Literal[6],
- *,
- maxqsize: int = ...,
- put_exc: bool = ...,
- loop: asyncio.AbstractEventLoop | None = ...,
- asyncutils.iters.tee(
- it: asyncutils._internal.prots.SupportsIteration[T],
- n: int,
- *,
- maxqsize: int = ...,
- put_exc: bool = ...,
- loop: asyncio.AbstractEventLoop | None = ...,
- Create
nindependent async generators from a single (async) iterableitthat yield the same items, caching items in a queue when needed.A background task is spawned to consume the iterable.Unlikeitertools.tee(), the returned iterators are plain async generators, and the flattening step with a linked list as specified in theitertoolsdocs is not done.maxqsize(defaultTEE_DEFAULT_MAX_QSIZE) specifies how many unproduced items can be consumed from the source ahead of the slowest consumer(s) before the background task and the faster consumers start blocking to wait for them. 0 or below indicates an unbounded queue.Ifput_excisTrue(defaultTEE_DEFAULT_PUT_EXC), an exception raised by the source iterable will be propagated as late as possible; that is, only when the caller gets to that point. Slower consumers are not immediately affected.Otherwise, the exception is raised in the background task used to consume the iterable, andQueueShutDownwill be propagated to callers waiting on consumers.
- async asyncutils.iters.to_deque[T](it: asyncutils._internal.prots.SupportsIteration[T]) collections.deque[T][source]¶
Collect all items in the (async) iterable
itinto adeque.
- async asyncutils.iters.to_list[T](it: asyncutils._internal.prots.SupportsIteration[T]) list[T][source]¶
Collect all items of an async iterable into a list. Faster than
collect().
- async asyncutils.iters.to_set[T: collections.abc.Hashable](it: asyncutils._internal.prots.SupportsIteration[T], frozen: Literal[False] = ...) set[T][source]¶
- async asyncutils.iters.to_set(it: asyncutils._internal.prots.SupportsIteration[T], frozen: Literal[True]) frozenset[T]
Collect all items in the (async) iterable
itinto a set or frozenset depending on thefrozenparameter (Falseby default).
- async asyncutils.iters.to_tuple[T](it: asyncutils._internal.prots.SupportsIteration[T]) tuple[T, Ellipsis][source]¶
Convert the output of
to_list()into a tuple.
- async asyncutils.iters.vecs_eq[T](
- u: asyncutils._internal.prots.SupportsIteration[T],
- v: asyncutils._internal.prots.SupportsIteration[T],
- cmpeq: collections.abc.Callable[[T, T], object] = ...,
- *,
- strict: bool = ...,
Whether the vectors
uandvare equal according tocmpeqcalled on each pair of items from iterating through them in parallel. IfstrictisFalse(defaultTrue), may returnTrueeven for differently-sized vectors.
- asyncutils.iters.window[T](
- it: asyncutils._internal.prots.SupportsIteration[T],
- size: int,
- step: int = ...,
Window an async iterable into an async generator of tuples of the specified size and step. You can send in a tuple
(size, step)to change the behaviour of the iterator.