asyncutils.iters

Functional and composable interface to get async generators from (async) iterables. Many of the algorithms here are taken from more_itertools, but some are unique to async.
However, since they must support both sync and async iterables, they are much less efficient than their sync counterparts.

Classes

Functions

aaccumulate(→ types.AsyncGeneratorType[T])

Async version of itertools.accumulate() that is not a class.

aadjacent(…)

For each item in the (async) iterable it, yield tuples of the form (is_within_dist, item), where is_within_dist is True iff the closest distance to an item satisfying pred is at most dist, and the call to pred is awaited iff await_pred=True is passed.

aall(→ bool)

Async version of all().

aall_equal(→ bool)

Whether all items in the (async) iterable are equal to each other according to the key function. Check for identity rather than equality if strict is True.

aall_unique(…)

Return whether all the items in the (async) iterable it are distinct (according to key, awaited if await_key=True is passed, if passed).

aany(→ bool)

Async version of any().

aappend(→ types.AsyncGeneratorType[T])

Append val to the (async) iterable it.

aargmax(…)

Return the index of the first occurrence of the maximum element in the (async) iterable it according to key, or default if empty.

aargmin(…)

Return the index of the first occurrence of the minimum element in the (async) iterable it according to key, or default if empty.

aargminmax(…)

Return a tuple of the indices of the first occurrences of the minimum and maximum elements in the (async) iterable it according to key, or default if empty.

aawgenf2agenf(→ collections.abc.Callable[P, ...)

Convert a function that returns an awaitable resolving to an async iterable into one returning an async generator.

abefore_and_after(→ tuple[types.AsyncGeneratorType[T], ...)

atakewhile(), but return all remaining items in the second async generator (after the first is consumed).

abfs(→ types.AsyncGeneratorType[T])

Breadth-first search on a start node start, given a function neighbours that returns an (async) iterable of neighbours to be traversed in order. If include_start is True, the start node is yielded first.

abrent(→ tuple[T, int, int])

ac3merge(→ types.AsyncGeneratorType[T])

Async version of functools._c3_merge() that doesn't assume the input is a synchronous iterable over mutable sequences of classes.

acanonical(→ list[T])

Return a canonicalized ordering of the items in it, which may change across different Python invocations or sessions.

acat(…)

Yield the sent value, starting with first (default None).

acollapse(→ types.AsyncGeneratorType[Any])

Flatten the (async) iterable it by at most levels levels, without collapsing objects of types specified in base_typ.

acombinations(→ types.AsyncGeneratorType[tuple[T, ...)

Async version of itertools.combinations() that is not a class.

acombinations_with_replacement(...)

Async version of itertools.combinations_with_replacement() that is not a class.

acompress(→ types.AsyncGeneratorType[T])

Async version of itertools.compress() that is not a class.

aconsume(→ None)

Advance the (async) iterable it by n steps, using a function-scoped executor created on demand where appropriate. If you want the item at the final position, use anth() instead.

aconvolve(→ types.AsyncGeneratorType[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.

acount(…)

Async version of itertools.count() that is not a class.

acount_cycle(→ types.AsyncGeneratorType[tuple[int, T]])

Yield tuples of the form (n, item), where item cycles through the iterable, caching its items during the first cycle, and n is the number of times the iterable has been completely cycled prior to yielding item.

acountdown(→ types.AsyncGeneratorType[int])

Count down from n to zero, excluding zero if it is to appear and include_zero is False (the default), by a step size of step.

acycle(→ types.AsyncGeneratorType[T])

Async version of itertools.cycle() that is not a class.

aderangements(→ types.AsyncGeneratorType[T])

Successive derangements of the elements in it of size r, or all sizes if not passed. Derangements are permutations with no fixed points.

adfs(→ types.AsyncGeneratorType[T])

Depth-first search on a start node start, given a function neighbours that returns an (async) iterable of neighbours to be traversed in order. If include_start is True, the start node is yielded first.

adft(→ types.AsyncGeneratorType[complex])

The discrete Fourier transform. O(n^2), since this library does not specialize in these operations.

adifference(…)

For an iterable with items a, b, c, etc., yield a, func(b, a), func(c, b), dropping a iff yield_initial=False was passed and awaiting the return value iff await_func=True was passed. Essentially the inverse of aaccumulate().

adistinct_permutations(...)

Successive distinct permutations of the elements in it of size r, or all sizes if not passed.

adouble_starmap(→ types.AsyncGeneratorType[T])

Like amap(), but the iterables should yield mappings that are unpacked as arguments to the function.

adropuntil(…)

Drop items from the iterable until the predicate called on the item holds.

adropuntil_exclusive(…)

Like adropuntil() but starts only after dropping the first truthy item.

adropwhile(…)

Async version of itertools.dropwhile() that is not a class.

adropwhile_exclusive(…)

Like adropwhile() but starts only after dropping the first falsy item.

advance_by(→ None)

aevery(→ types.AsyncGeneratorType[T])

Yield every n-th item from an (async) iterable, optionally skipping the first item.

aevery_other(→ types.AsyncGeneratorType[T])

Yield every other item from an (async) iterable, optionally skipping the first item.

afactor(→ types.AsyncGeneratorType[int])

Generate the prime factors of n asynchronously. Do not rely on the resultant order.

afilter(…)

Async version of filter that is not a class.

afilterfalse(…)

Async version of itertools.filterfalse() that is not a class.

afirst(→ T)

Return the first item in the (async) iterable it, or default if passed and it is empty.

afirstfalse(→ T)

Return the first item in the (async) iterable it that fails the predicate, or default if passed and there is no such item, and raise StopAsyncIteration otherwise.

afirstfalse_or_first(…)

afirstfalse_or_last(…)

afirsttrue(→ T)

Return the first item in the (async) iterable it that satisfies the predicate, or default if passed and there is no such item, and raise StopAsyncIteration otherwise.

afirsttrue_or_first(…)

afirsttrue_or_last(…)

aflatten(→ types.AsyncGeneratorType[T])

Flatten one level of nesting using AChain and return an async iterator over it.

aflatten_tensor(→ types.AsyncGeneratorType[Any])

acollapse(), but using a different, more memory-efficient strategy that does not support the levels parameter.

aforever(→ types.AsyncGeneratorType[None])

Yield None forever. Equivalent to arepeat(None).

afreivalds(→ bool)

Determine if the matrix product of A and B equals C. This is the probabilistic Freivalds algorithm. O(kn^2) time, with a false positive rate of at most 2^(-k) and no false negatives.

agather(→ list[T])

Wrap asyncio.gather() to accept (async) iterables as the first argument, so that unpacking is not needed.

agives(→ types.AsyncGeneratorType[T])

Yield the given value, then return.

agroupby(…)

Async version of itertools.groupby() that is not a class.

agroupby_transform(…)

Async version of more_itertools.groupby_transform().

agrouper(→ types.AsyncGeneratorType[tuple[T | None, ...)

aguessmax(…)

Optimal solution to the secretary problem, using key to 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_cb is called on every rejected candidate once rejected, its return value awaited if await_cb=True is passed, and no more than one candidate is ever stored. This Numberphile video proves that the approach used is best.

aguessmin(…)

Like aguessmax(), but guesses the minimum item instead.

aichunked(...)

aidft(→ types.AsyncGeneratorType[complex])

The inverse discrete Fourier transform. O(n^2) just like adft().

aiequals(→ bool)

ailen(→ int)

Return the length of the (async) iterable it, consuming it entirely.

ainterleave_evenly(→ types.AsyncGeneratorType[T])

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.

ainterleave_randomly(→ types.AsyncGeneratorType[T])

Interleave items of the iterables randomly, skipping exhausted iterables.

ainterleave_stopearly(→ types.AsyncGeneratorType[T])

Yield the items from the iterables in a round-robin fashion until at least one is exhausted.

aintersend(→ types.AsyncGeneratorType[tuple[T, R]])

Feed i1 and i2 into each other and yield tuples of the form (yielded_from_i1, yielded_from_i2).

aintersperse(→ types.AsyncGeneratorType[T])

Yield e, then the next n items in it, and repeat until it is exhausted.

aisempty(→ bool)

Return whether the (async) iterable it is empty.

aislice(…)

Async version of itertools.islice() that is not a class.

aisprime(→ bool)

Probabilistically test for primality of n. O(log^3 n), with false-positive rate below 2^(-128) for integers above 10^24.

aiter_idx(→ types.AsyncGeneratorType[int])

Yield the indices at which value occurs in it within start and stop.

aiterate(→ types.AsyncGeneratorType[T])

Yield start, then the awaited output of f called on the previous output repeatedly.

aiterexcept(→ types.AsyncGeneratorType[T])

Yield the awaited output of first, then f called with no arguments repeatedly until an exception present in exc occurs.

alast(→ T)

Return the last item in the (async) iterable it, or default if passed and it is empty.

all_max(…)

all_min(…)

aloops(→ types.AsyncGeneratorType[None])

Yield None n times. Equivalent to base.take(aforever(), n) and arepeat(None, n), but without creating intermediate integers.

amap(…)

Async version of map that is not a class, with await_ dictating whether the return value of the function is to be awaited before yielding.

amapif(…)

Essentially the restriction of amultimapif() to one (async) iterable.

amatmul(→ types.AsyncGeneratorType[tuple[T, Ellipsis]])

Matrix multiplication of M and N. O(n^3) time, since this library does not specialize in these operations.

amatprod(→ T)

Return the product of the matrices in the (async) iterable, preceded by start if passed.

amax(…)

Async version of max().

amerge_sorted_by(…)

Async version of heapq.merge().

amin(…)

Async version of min().

aminmax(…)

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.

aminmax_keyed(…)

Like aminmax(), but performs comparisons according to the return value of key.

amultifilter(…)

Composition of afilter() and azip().

amultifilterfalse(…)

Composition of afilterfalse() and azip().

amultimapif(…)

Composition of astarmap(), afilter() and azip().

amultistarfilter(…)

Composition of astarfilter() and azip().

amultistarfilterfalse(…)

Composition of astarfilterfalse() and azip().

amultistarmapif(…)

Composition of astarmap() and amultistarfilter().

ancycles(→ types.AsyncGeneratorType[T])

Yield the items in the (async) iterable it over and over for a total of n cycles.

anth(→ T)

Return the n-th item of the (async) iterable it, or default if passed and there is no such item.

anth_combination(→ types.AsyncGeneratorType[T])

Return the n-th combination of r elements from the input iterable it, in lexicographic order.

anth_combination_with_replacement(→ tuple[T, Ellipsis])

Return the n-th combination of r elements from the input iterable it, in lexicographic order, allowing individual elements to be repeated.

anth_or_last(→ T)

Return the n-th item in the (async) iterable it, or the last item if out of bounds, or default if passed and it is empty.

anth_permutation(→ tuple[T, Ellipsis])

Return the n-th permutation of r elements from the input iterable it, in lexicographic order.

anth_product(→ tuple[T, Ellipsis])

Return the n-th item of the Cartesian product of the input iterables its, in lexicographic order, with each iterable repeated repeat times.

aonline_sorter(…)

aouter_product(→ types.AsyncGeneratorType[list[V]])

apadded(→ types.AsyncGeneratorType[T])

Yield the items in the (async) iterable it, followed by fillvalue repeatedly, such that the iterable is fully consumed and the result has length at least n if passed.

apadnone(→ types.AsyncGeneratorType[T | None])

Yield the items in the (async) iterable it, followed by None repeatedly, such that the iterable is fully consumed and the result has length at least n if passed.

apairwise(→ types.AsyncGeneratorType[tuple[T, T]])

Async version of itertools.pairwise() that is not a class.

apartition(→ tuple[types.AsyncGeneratorType[T], ...)

Return a tuple (fg, tg). tg is an async generator yielding the items in it passing the predicate, and fg the others.

apermutations(→ types.AsyncGeneratorType[tuple[T, ...)

Async version of itertools.permutations() that is not a class.

apolynomial_derivative(→ types.AsyncGeneratorType[T])

Compute the coefficients of the derivative of a polynomial. Both input and output iterables are in order of descending powers.

apolynomial_eval(→ T)

Evaluate a polynomial at x given its coefficients in order of descending powers.

apolynomial_from_roots(→ types.AsyncGeneratorType[T])

Generate the coefficients of a polynomial given its roots in order of descending powers.

apowers(→ types.AsyncGeneratorType[T])

Yield start, start*base, start*base*base, ...

apowers_of_two(→ types.AsyncGeneratorType[int])

Optimized version of apowers() using bit shift operations for powers of two, four, eight, etc. Yield init<<init_shift, init<<init_shift+shift, init<<init_shift+2*shift, ...

apowerset(→ types.AsyncGeneratorType[tuple[T, Ellipsis]])

Yield all the subsets of the (async) iterable it (by index!) as tuples, starting with the empty tuple.

apowerset_of_sets(…)

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 if frozen is True (the default) and set's otherwise.

aprepend(→ types.AsyncGeneratorType[T])

Prepend val to the (async) iterable it.

aprod(→ T)

Return the product of the items in the (async) iterable, preceded by start if passed.

aproduct(…)

Async version of itertools.product() that is not a class.

aquantify(→ int)

Return the number of items in the (async) iterable for which the predicate is true.

arandom_combination(→ types.AsyncGeneratorType[T])

Draw r items at random from the input iterable it, without replacement.

arandom_combination_with_replacement(...)

Draw r items at random from the input iterable it, with replacement.

arandom_derangement(→ tuple[T, Ellipsis])

Generate a random derangement of items in the (async) iterable it.

arandom_permutation(→ types.AsyncGeneratorType[T])

Choose a random permutation of the elements in it of size r, or all sizes if not passed.

arandom_product(→ types.AsyncGeneratorType[T])

Draw n items from each of the input iterables its at random.

arange(…)

Async version of range that is not a class.

arepeat(→ types.AsyncGeneratorType[T])

Async version of itertools.repeat() that is not a class.

arepeat_each(→ types.AsyncGeneratorType[T])

Yield each item in the (async) iterable it exactly n times before advancing.

arepeat_func(→ types.AsyncGeneratorType[T])

Call the async function f with arguments a repeatedly for times times, or indefinitely if times is not passed, and yield the results awaited.

arepeat_last(→ types.AsyncGeneratorType[T])

Yield all the items in the (async) iterable it, then keep yielding the last item forever, or default if the iterable was empty, stopping if it was not passed. If default was RAISE, raise ItemsExhausted.

areshape(…)

Change the shape of a tensor according to shape. For an integer shape, the matrix must be 2D and shape is the number of output columns.

areversed(→ types.AsyncGeneratorType[T])

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.

aroundrobin(→ types.AsyncGeneratorType[T])

Yield items from the given (async) iterables in round-robin order, skipping exhausted iterables. Prefer over aroundrobin2() for less iterables.

aroundrobin2(→ types.AsyncGeneratorType[T])

Yield items from the given (async) iterables in round-robin order, skipping exhausted iterables. Prefer over aroundrobin() for more iterables.

arunlength_decode(→ types.AsyncGeneratorType[T])

Inverse of the above, but takes any (async) iterable and always gives an async generator.

arunlength_encode(→ types.AsyncGeneratorType[tuple[T, ...)

Compress an (async) iterable into an async generator of pairs with run-length encoding. Items in the result are in the form (item, count), where item is an item from the input iterable and count is the number of times it is repeated consecutively.

arunning_mean(→ types.AsyncGeneratorType[T])

Repeatedly yield the mean of the items in the iterable so far, and advance the iterable.

arunning_median(→ types.AsyncGeneratorType[T])

Yield the median of all the items seen from it within a window of size maxlen, then advance it.

asample_l(→ list[T])

Chooses k items from an (async) iterable of items, where each item is chosen with equal probability. rrange and rand should be the randrange() and random() methods of a random device respectively. This is Algorithm L.

asample_weighted(→ list[T])

Choose k items from an (async) iterable of (item, weight) pairs, where the probability of each item being chosen is proportional to its weight. rrange and rand should be the randrange() and random() methods of a random device respectively. This is the A-Chao with Jumps reservoir sampling algorithm.

asattolo(→ list[T])

Return a list representing a random full-length permutation of the items in it.

asendstream(→ types.AsyncGeneratorType[T])

Feed i2 into i1 and yield the results.

aserialize(→ types.AsyncGeneratorType[T])

Protect an (async) iterable from being consumed by many parties concurrently by applying an async lock.

aside_effect(…)

asieve(→ types.AsyncGeneratorType[int])

Yield prime numbers strictly smaller than n in order in an async generator.

asliced(→ types.AsyncGeneratorType[T])

asorted(…)

Async version of sorted(). O(n log n) time and O(n) space, but nowhere near as optimized as the builtin version.

asplitat(→ types.AsyncGeneratorType[list[T]])

Split an async iterator at each item satisfying pred, with keep_sep dictating whether the separator is to be included as the last item of each list.

aspy(→ tuple[types.AsyncGeneratorType[T], ...)

Return an async generator containing the first n items, and another containing all the original items.

astarfilter(…)

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.

astarfilterfalse(…)

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.

astarmap(…)

Async version of itertools.starmap() that is not a class. await_ specifies whether to await the return value of the transformation function.

astarmap_with_kwds(→ types.AsyncGeneratorType[T])

Like amap(), but the iterable should yield tuples of the form (args, kwargs), where args is an iterable of positional arguments and kwargs is a mapping of keyword arguments.

asubslices(→ types.AsyncGeneratorType[tuple[T, Ellipsis]])

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.

asubstr_indices(…)

Yield tuples of the form (substr, start, end), where substr is a contiguous subsequence of seq starting at index start and ending at index end-1 (such that its length is end-start).

asubstrings(→ types.AsyncGeneratorType[tuple[T, Ellipsis]])

Yield all contiguous subsequences of the (async) iterable it as tuples, in increasing order of length.

asum(→ T)

Return the sum of the items in the (async) iterable, preceded by start if passed.

asum_of_squares(→ T)

Return the sum of squares of items in an (async) iterable of numbers as a number of the same type.

asumprod(→ 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.

at_most_one(…)

atabulate(…)

Composition of amap() and acount().

atabulate_finite(…)

atail(→ types.AsyncGeneratorType[T])

Yield the last n items from the (async) iterable it.

atakeuntil(…)

Take items from the iterable until the predicate called on the item holds.

atakeuntil_inclusive(…)

Like atakewhile() but stops only after yielding the first truthy item.

atakewhile(…)

Async version of itertools.takewhile() that is not a class.

atakewhile_inclusive(…)

Like atakewhile() but stops only after yielding the first falsy item.

atranspose(→ types.AsyncGeneratorType[tuple[T, Ellipsis]])

Compute the transpose of a matrix.

atriplewise(→ types.AsyncGeneratorType[tuple[T, T, T]])

Yield overlapping triples of items from an (async) iterable.

aunique(→ types.AsyncGeneratorType[T])

Yield unique elements from it in sorted order, according to key, which should not be too expensive. If reverse is True, yield in descending order.

aunique_everseen(…)

Yield items from the (async) iterable it, without yielding items already previously yielded.

aunique_justseen(…)

Yield items from the (async) iterable it, without yielding consecutive duplicate items.

aunique_to_each(→ types.AsyncGeneratorType[T])

Given multiple (async) iterables, yield every item that is only seen in exactly one of the iterables.

aunzip(…)

awindowed_complete(...)

Yield tuples of the form (prev, window, next), where window is a tuple of n items from the (async) iterable it, and prev and next are tuples of all the items before and after that window, respectively. Consumes and caches the whole iterable, so use with caution.

awrap(→ types.AsyncGeneratorType[T])

Wrap the (async) iterable it by yielding start first, then the items in it, then end.

awrapf(…)

Call before when the iterable starts, then yield the items in it, then call after as long as before did not raise and the iterable was converted to an async generator successfully. The return value of each function is awaited if it doesn't raise TypeError.

azip(…)

Async version of zip that is not a class.

azip_offset(…)

aziplongest(…)

Async version of itertools.zip_longest() that is not a class. The first overload does not accept fillvalue, because passing it with only one iterable does not make sense.

basic_collect(→ list[T])

Return a list of the first n items in the (async) iterable it, signalling no error if there are not enough items.

batch(→ types.AsyncGeneratorType[list[T]])

More flexible but slightly slower implementation of batch2(), supporting timeouts waiting for each item, that raises ValueError instead of ItemsExhausted in the case of the length of the iterable being indivisible by the batch size.

batch2(…)

Batch an (async) iterable into an async generator of lists. If strict=True is specified, raise ItemsExhausted on the last batch if it is discovered then that the iterable does not have enough items for a complete batch.

batch_process(→ types.AsyncGeneratorType[R])

Apply processor to each batch of size size in items and yield the results awaited.

buffer(→ types.AsyncGeneratorType[T])

circular_shifts(→ types.AsyncGeneratorType[tuple[T, ...)

cloned(→ types.AsyncGeneratorType[T])

Yield copies of the items in the (async) iterable it, as returned by copy().

coalesce(…)

counts(…)

decreasing_runs(→ types.AsyncGeneratorType[list[T]])

diff_with(→ FirstMisMatch[T, ...)

distribute(…)

duplicates(…)

empty_agen(→ types.AsyncGeneratorType[Never])

Return an async generator that yields nothing. Due to async generator finalization issues, this is not a constant like yield_to_event_loop.

extract(→ list[asyncio.Future[T]])

extract_monotonic(→ types.AsyncGeneratorType[T])

filter_identical(→ types.AsyncGeneratorType[T])

flat_map(…)

Async version of map that is not a class, with await_ dictating whether the return value of the function is to be awaited before yielding.

fmap(→ list[T])

Return a list of the results of calling each async function in the first argument (an (async) iterable of functions), with the provided arguments.

fmap_parallel(→ types.AsyncGeneratorType[T])

Like fmap_sequential(), but starts background tasks for each call.

fmap_sequential(→ types.AsyncGeneratorType[T])

Like fmap(), but only call a function after the last completes and the result is gotten.

fuse(…)

gray_product(…)

group_from(→ types.AsyncGeneratorType[tuple[T, ...)

Yield tuples of the form (key, group), where group is an async generator taken from values and corresponding to the same run of keys in keys. If strict=False is passed, an error is not raised when keys and values differ in length.

hamming_dist(→ int)

Return the Hamming distance between two (async) iterables, using cmpeq to check for equality if passed.

increasing_runs(→ types.AsyncGeneratorType[list[T]])

is_sorted(…)

iter_task(→ asyncio.Task[float])

Return a task that calls summaryf on the passed (async) iterable and returns the time taken to run it. By default, summaryf consumes it fully.

iterate_with_key(…)

locate(…)

longest_common_prefix(→ types.AsyncGeneratorType[T])

lstrip(…)

map_if_else(…)

map_on_map(…)

Apply a transformation on an (async) iterable on top of another.

map_windows(…)

mark_ends(→ types.AsyncGeneratorType[tuple[bool, bool, T]])

mat_vec_mul(→ types.AsyncGeneratorType[int])

Multiplication of a matrix M and a vector V. O(n^2).

merge(→ types.AsyncGeneratorType[T])

pad_using(…)

partial_product(…)

partitions(→ types.AsyncGeneratorType[list[tuple[T, ...)

product_index(…)

rstrip(…)

scan(…)

sort_together(…)

split_when(→ types.AsyncGeneratorType[list[T]])

stagger(…)

strip(…)

tee(…)

to_deque(→ collections.deque[T])

Collect all items in the (async) iterable it into a deque.

to_list(→ list[T])

Collect all items of an async iterable into a list. Faster than collect().

to_set(…)

Collect all items in the (async) iterable it into a set or frozenset depending on the frozen parameter (False by default).

to_tuple(→ tuple[T, Ellipsis])

Convert the output of to_list() into a tuple.

vecs_eq(→ bool)

Whether the vectors u and v are equal according to cmpeq called on each pair of items from iterating through them in parallel. If strict is False (default True), may return True even for differently-sized vectors.

window(→ types.AsyncGeneratorType[tuple[T, Ellipsis], ...)

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.

Module Contents

class asyncutils.iters.FirstMisMatch[T, R]

Bases: NamedTuple

async collect_left() list[T]
async collect_right() list[R]
remainder(strict: bool = ...) types.AsyncGeneratorType[tuple[T, R]]
i: int
lrem: types.AsyncGeneratorType[T]
rrem: types.AsyncGeneratorType[R]
class asyncutils.iters.Longer[T]

Bases: NamedTuple

async collect() list[T]
i: int
rrem: types.AsyncGeneratorType[T]
class asyncutils.iters.Shorter[T]

Bases: NamedTuple

async collect() list[T]
i: int
lrem: types.AsyncGeneratorType[T]
asyncutils.iters.aaccumulate[T](
it: asyncutils._internal.prots.SupportsIteration[T],
func: collections.abc.Callable[[T, T], T] = ...,
*,
initial: T | None = ...,
) types.AsyncGeneratorType[T][source]

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] = ...,
) types.AsyncGeneratorType[tuple[bool, T]][source]
asyncutils.iters.aadjacent(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
dist: int = ...,
*,
await_pred: Literal[True],
) types.AsyncGeneratorType[tuple[bool, T]]

For each item in the (async) iterable it, yield tuples of the form (is_within_dist, item), where is_within_dist is True iff the closest distance to an item satisfying pred is at most dist, and the call to pred is awaited iff await_pred=True is 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 = ...,
) bool[source]

Whether all items in the (async) iterable are equal to each other according to the key function. Check for identity rather than equality if strict is True.

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] = ...,
) bool
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],
) bool

Return whether all the items in the (async) iterable it are distinct (according to key, awaited if await_key=True is 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 val to the (async) iterable it.

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] = ...,
) int[source]
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],
) int
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 it according to key, or default if 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] = ...,
) int[source]
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],
) int
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 it according to key, or default if 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] = ...,
) tuple[int, int][source]
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],
) tuple[int, int]
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] = ...,
) tuple[int, int] | R
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],
) tuple[int, int] | R
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 it according to key, or default if empty.

asyncutils.iters.aawgenf2agenf[T, **P](
f: collections.abc.Callable[P, collections.abc.AsyncIterable[T]],
/,
) collections.abc.Callable[P, types.AsyncGeneratorType[T]][source]

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],
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]][source]

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 = ...,
) types.AsyncGeneratorType[T][source]

Breadth-first search on a start node start, given a function neighbours that returns an (async) iterable of neighbours to be traversed in order. If include_start is True, 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_node returning the next node from the previous.
Return a tuple (node, la, mu), where node is the first node involved in a cycle, mu its index (the least number of times next_node was applied to get node), and la the cycle length.

Note

next_node should be deterministic. Also, if there is no cycle, the algorithm hangs indefinitely.

asyncutils.iters.ac3merge[T](
seqs: asyncutils._internal.prots.SupportsIteration[collections.abc.MutableSequence[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 (default None).

asyncutils.iters.acollapse(
it: asyncutils._internal.prots.SupportsIteration[object],
base_typ: tuple[type, Ellipsis] | type = ...,
levels: int | None = ...,
) types.AsyncGeneratorType[Any][source]

Flatten the (async) iterable it by at most levels levels, without collapsing objects of types specified in base_typ.

asyncutils.iters.acombinations[T](
it: asyncutils._internal.prots.SupportsIteration[T],
r: int,
) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]

Async version of itertools.combinations() that is not a class.

asyncutils.iters.acombinations_with_replacement[T](
it: asyncutils._internal.prots.SupportsIteration[T],
r: int,
) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]

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],
) types.AsyncGeneratorType[T][source]

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 it by n steps, using a function-scoped executor created on demand where appropriate. If you want the item at the final position, use anth() instead.

asyncutils.iters.aconvolve[T: (int, float, complex)](
signal: asyncutils._internal.prots.SupportsIteration[T],
kernel: asyncutils._internal.prots.SupportsIteration[T],
) types.AsyncGeneratorType[T][source]

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 = ...,
) types.AsyncGeneratorType[tuple[int, T]][source]

Yield tuples of the form (n, item), where item cycles through the iterable, caching its items during the first cycle, and n is the number of times the iterable has been completely cycled prior to yielding item.

asyncutils.iters.acountdown(n: int, step: int = ..., *, include_zero: bool = ...) types.AsyncGeneratorType[int][source]

Count down from n to zero, excluding zero if it is to appear and include_zero is False (the default), by a step size of step.

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 it of size r, 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 = ...,
) types.AsyncGeneratorType[T][source]

Depth-first search on a start node start, given a function neighbours that returns an (async) iterable of neighbours to be traversed in order. If include_start is True, 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] = ...,
) types.AsyncGeneratorType[R][source]
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],
) types.AsyncGeneratorType[R]
asyncutils.iters.adifference(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
yield_initial: bool = ...,
await_func: Literal[False] = ...,
) types.AsyncGeneratorType[T]
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],
) types.AsyncGeneratorType[T]

For an iterable with items a, b, c, etc., yield a, func(b, a), func(c, b), dropping a iff yield_initial=False was passed and awaiting the return value iff await_func=True was passed. Essentially the inverse of aaccumulate().

asyncutils.iters.adistinct_permutations[T](
it: asyncutils._internal.prots.SupportsIteration[T],
r: int | None = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]

Successive distinct permutations of the elements in it of size r, 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]],
/,
) types.AsyncGeneratorType[T][source]

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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.adropuntil(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]

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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.adropuntil_exclusive(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]

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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.adropwhile(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]

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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.adropwhile_exclusive(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]

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 = ...,
) types.AsyncGeneratorType[T][source]

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 = ...,
) types.AsyncGeneratorType[T][source]

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 n asynchronously. 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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.afilter(
f: collections.abc.Callable[[T], collections.abc.Awaitable[object]] | None,
it: asyncutils._internal.prots.SupportsIteration[T],
await_: Literal[True],
) types.AsyncGeneratorType[T]

Async version of filter that is not a class.

asyncutils.iters.afilterfalse[T](
f: collections.abc.Callable[[T], object] | None,
it: asyncutils._internal.prots.SupportsIteration[T],
await_: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.afilterfalse(
f: collections.abc.Callable[[T], collections.abc.Awaitable[object]] | None,
it: asyncutils._internal.prots.SupportsIteration[T],
await_: Literal[True],
) types.AsyncGeneratorType[T]

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, or default if passed and it is empty.

async asyncutils.iters.afirstfalse[T](
it: asyncutils._internal.prots.SupportsIteration[T],
default: T | None = ...,
pred: collections.abc.Callable[[T], object] = ...,
) T[source]

Return the first item in the (async) iterable it that fails the predicate, or default if passed and there is no such item, and raise StopAsyncIteration otherwise.

asyncutils.iters.afirstfalse_or_first[T](
it: asyncutils._internal.prots.SupportsIteration[T],
*,
pred: collections.abc.Callable[[T], object] | None = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.afirstfalse_or_first(
it: asyncutils._internal.prots.SupportsIteration[T],
default: T,
pred: collections.abc.Callable[[T], object] | None = ...,
*,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T]
asyncutils.iters.afirstfalse_or_first(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]
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],
) types.AsyncGeneratorType[T]
asyncutils.iters.afirstfalse_or_last[T](
it: asyncutils._internal.prots.SupportsIteration[T],
*,
pred: collections.abc.Callable[[T], object] | None = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.afirstfalse_or_last(
it: asyncutils._internal.prots.SupportsIteration[T],
default: T,
pred: collections.abc.Callable[[T], object] | None = ...,
*,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T]
asyncutils.iters.afirstfalse_or_last(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]
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],
) types.AsyncGeneratorType[T]
async asyncutils.iters.afirsttrue[T](
it: asyncutils._internal.prots.SupportsIteration[T],
default: T | None = ...,
pred: collections.abc.Callable[[T], object] = ...,
) T[source]

Return the first item in the (async) iterable it that satisfies the predicate, or default if passed and there is no such item, and raise StopAsyncIteration otherwise.

asyncutils.iters.afirsttrue_or_first[T](
it: asyncutils._internal.prots.SupportsIteration[T],
*,
pred: collections.abc.Callable[[T], object] | None = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.afirsttrue_or_first(
it: asyncutils._internal.prots.SupportsIteration[T],
default: T,
pred: collections.abc.Callable[[T], object] | None = ...,
*,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T]
asyncutils.iters.afirsttrue_or_first(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]
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],
) types.AsyncGeneratorType[T]
asyncutils.iters.afirsttrue_or_last[T](
it: asyncutils._internal.prots.SupportsIteration[T],
*,
pred: collections.abc.Callable[[T], object] | None = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.afirsttrue_or_last(
it: asyncutils._internal.prots.SupportsIteration[T],
default: T,
pred: collections.abc.Callable[[T], object] | None = ...,
*,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T]
asyncutils.iters.afirsttrue_or_last(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]
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],
) types.AsyncGeneratorType[T]
asyncutils.iters.aflatten[T](
it: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
) types.AsyncGeneratorType[T][source]

Flatten one level of nesting using AChain and return an async iterator over it.

asyncutils.iters.aflatten_tensor(
tensor: asyncutils._internal.prots.SupportsIteration[object],
base_typ: tuple[type, Ellipsis] | type = ...,
) types.AsyncGeneratorType[Any][source]

acollapse(), but using a different, more memory-efficient strategy that does not support the levels parameter.

asyncutils.iters.aforever() types.AsyncGeneratorType[None][source]

Yield None forever. Equivalent to arepeat(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 = ...,
) bool[source]

Determine if the matrix product of A and B equals C. 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 = ...,
) list[T][source]

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] = ...,
) types.AsyncGeneratorType[tuple[T, types.AsyncGeneratorType[T]]][source]
asyncutils.iters.agroupby(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], R],
) types.AsyncGeneratorType[tuple[R, types.AsyncGeneratorType[T]]]

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] = ...,
) types.AsyncGeneratorType[tuple[T, types.AsyncGeneratorType[T]]][source]
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] = ...,
) types.AsyncGeneratorType[tuple[R, types.AsyncGeneratorType[T]]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, S]]
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],
) types.AsyncGeneratorType[tuple[T, S]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, S]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, S]]
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],
) types.AsyncGeneratorType[tuple[R, S]]
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],
) types.AsyncGeneratorType[tuple[R, S]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, types.AsyncGeneratorType[T]]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, S]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, S]]
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],
) types.AsyncGeneratorType[tuple[R, S]]
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],
) types.AsyncGeneratorType[tuple[R, S]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, types.AsyncGeneratorType[V]]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, S]]
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],
) types.AsyncGeneratorType[tuple[R, S]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, types.AsyncGeneratorType[V]]]
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] = ...,
) types.AsyncGeneratorType[tuple[R, S]]
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],
) types.AsyncGeneratorType[tuple[R, S]]

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 = ...,
) types.AsyncGeneratorType[tuple[T | None, Ellipsis]][source]
Collect items of the (async) iterable it into tuples of length n each.
If fillvalue is RAISE, raise ValueError if the last group is not of length n.
Otherwise, pad the last group with fillvalue to length n if 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 = ...,
) T[source]
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] = ...,
) T
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],
) T

Optimal solution to the secretary problem, using key to 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_cb is called on every rejected candidate once rejected, its return value awaited if await_cb=True is 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 = ...,
) T[source]
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] = ...,
) T
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],
) T

Like aguessmax(), but guesses the minimum item instead.

asyncutils.iters.aichunked[T](
it: asyncutils._internal.prots.SupportsIteration[T],
n: int,
) types.AsyncGeneratorType[asyncutils.iterclasses.AChain[T]][source]
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 = ...,
) types.AsyncGeneratorType[T][source]

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](
its: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[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],
) types.AsyncGeneratorType[tuple[T, R]][source]

Feed i1 and i2 into 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 next n items in it, and repeat until it is exhausted.

async asyncutils.iters.aisempty(it: asyncutils._internal.prots.SupportsIteration[object]) bool[source]

Return whether the (async) iterable it is empty.

Note

This advances the iterable on success and discards the item. If the item is needed, call afirst() instead and catch StopAsyncIteration or pass a default value.

asyncutils.iters.aislice[T](
it: asyncutils._internal.prots.SupportsIteration[T],
stop: SupportsIndex | None = ...,
/,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.aislice(
it: asyncutils._internal.prots.SupportsIteration[T],
start: SupportsIndex | None,
stop: SupportsIndex | None,
step: SupportsIndex | None = ...,
/,
) types.AsyncGeneratorType[T]

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 = ...,
) types.AsyncGeneratorType[int][source]

Yield the indices at which value occurs in it within start and stop.

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 of f called 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]] = ...,
) types.AsyncGeneratorType[T][source]

Yield the awaited output of first, then f called with no arguments repeatedly until an exception present in exc occurs.

async asyncutils.iters.alast[T](it: asyncutils._internal.prots.SupportsIteration[T], default: T = ...) T[source]

Return the last item in the (async) iterable it, or default if passed and it is 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] = ...,
) list[T][source]
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],
) list[T]
async asyncutils.iters.all_max(
it: asyncutils._internal.prots.SupportsIteration[T],
default: T = ...,
*,
await_key: Literal[False] = ...,
) list[T]
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] = ...,
) list[T][source]
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],
) list[T]
async asyncutils.iters.all_min(
it: asyncutils._internal.prots.SupportsIteration[T],
default: T = ...,
*,
await_key: Literal[False] = ...,
) list[T]
asyncutils.iters.aloops(n: int) types.AsyncGeneratorType[None][source]

Yield None n times. Equivalent to base.take(aforever(), n) and arepeat(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] = ...,
) types.AsyncGeneratorType[R][source]
asyncutils.iters.amap(
f: collections.abc.Callable[[T], R],
it: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
await_: Literal[False] = ...,
strict: Literal[False] = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
asyncutils.iters.amap(
f: collections.abc.Callable[[*tuple[T, ...]], collections.abc.Awaitable[R]],
/,
*its: asyncutils._internal.prots.SupportsIteration[T],
await_: Literal[True],
strict: bool = ...,
) types.AsyncGeneratorType[R]
asyncutils.iters.amap(
f: collections.abc.Callable[[*tuple[T, ...]], R],
/,
*its: asyncutils._internal.prots.SupportsIteration[T],
await_: Literal[False] = ...,
strict: bool = ...,
) types.AsyncGeneratorType[R]

Async version of map that is not a class, with await_ 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] = ...,
) types.AsyncGeneratorType[R][source]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]

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]],
) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]

Matrix multiplication of M and N. 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 start if 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] = ...,
) T
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] = ...,
) T
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],
) T
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],
) T

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 = ...,
) types.AsyncGeneratorType[T][source]
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 = ...,
) types.AsyncGeneratorType[T]
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 = ...,
) types.AsyncGeneratorType[T]

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] = ...,
) T
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] = ...,
) T
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],
) T
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],
) T

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] = ...,
) tuple[T, T]
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,
) tuple[T, T] | 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],
) tuple[T, T]
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,
) tuple[T, T] | 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] = ...,
) tuple[T, T]
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,
) tuple[T, T] | 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],
) tuple[T, T]
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,
) tuple[T, T] | R

Like aminmax(), but performs comparisons according to the return value of key.

asyncutils.iters.amultifilter[T](
pred: collections.abc.Callable[[tuple[T]], object],
it: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
strict: bool = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T]][source]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
asyncutils.iters.amultifilter(
pred: collections.abc.Callable[[tuple[T, Ellipsis]], object],
/,
*its: asyncutils._internal.prots.SupportsIteration[T],
strict: bool = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]
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],
) types.AsyncGeneratorType[tuple[T]]
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],
) types.AsyncGeneratorType[tuple[T, R]]
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],
) types.AsyncGeneratorType[tuple[T, R, V]]
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],
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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],
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
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],
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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],
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]

Composition of afilter() and azip().

asyncutils.iters.amultifilterfalse[T](
pred: collections.abc.Callable[[tuple[T]], object],
it: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
strict: bool = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T]][source]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
asyncutils.iters.amultifilterfalse(
pred: collections.abc.Callable[[tuple[T, Ellipsis]], object],
/,
*its: asyncutils._internal.prots.SupportsIteration[T],
strict: bool = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]
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],
) types.AsyncGeneratorType[tuple[T]]
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],
) types.AsyncGeneratorType[tuple[T, R]]
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],
) types.AsyncGeneratorType[tuple[T, R, V]]
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],
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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],
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
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],
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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],
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]

Composition of afilterfalse() and azip().

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] = ...,
) types.AsyncGeneratorType[R][source]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]

Composition of astarmap(), afilter() and azip().

asyncutils.iters.amultistarfilter[T](
pred: collections.abc.Callable[[T], object],
it: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
strict: bool = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T]][source]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
asyncutils.iters.amultistarfilter(
pred: collections.abc.Callable[[*tuple[T, ...]], object],
/,
*its: asyncutils._internal.prots.SupportsIteration[T],
strict: bool = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]
asyncutils.iters.amultistarfilter(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
strict: bool = ...,
await_pred: Literal[True],
) types.AsyncGeneratorType[tuple[T]]
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],
) types.AsyncGeneratorType[tuple[T, R]]
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],
) types.AsyncGeneratorType[tuple[T, R, V]]
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],
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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],
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
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],
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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],
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]

Composition of astarfilter() and azip().

asyncutils.iters.amultistarfilterfalse[T](
pred: collections.abc.Callable[[T], object],
it: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
strict: bool = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T]][source]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
asyncutils.iters.amultistarfilterfalse(
pred: collections.abc.Callable[[*tuple[T, ...]], object],
/,
*its: asyncutils._internal.prots.SupportsIteration[T],
strict: bool = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]
asyncutils.iters.amultistarfilterfalse(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
strict: bool = ...,
await_pred: Literal[True],
) types.AsyncGeneratorType[tuple[T]]
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],
) types.AsyncGeneratorType[tuple[T, R]]
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],
) types.AsyncGeneratorType[tuple[T, R, V]]
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],
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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],
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
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],
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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],
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]

Composition of astarfilterfalse() and azip().

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] = ...,
) types.AsyncGeneratorType[R][source]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]

Composition of astarmap() and amultistarfilter().

asyncutils.iters.ancycles[T](it: asyncutils._internal.prots.SupportsIteration[T], n: int) types.AsyncGeneratorType[T][source]

Yield the items in the (async) iterable it over and over for a total of n cycles.

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) iterable it, or default if 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 of r elements from the input iterable it, in lexicographic order.

async asyncutils.iters.anth_combination_with_replacement[T](
it: asyncutils._internal.prots.SupportsIteration[T],
r: int,
n: int,
) tuple[T, Ellipsis][source]

Return the n-th combination of r elements from the input iterable it, 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) iterable it, or the last item if out of bounds, or default if passed and it is 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 of r elements from the input iterable it, 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 iterables its, in lexicographic order, with each iterable repeated repeat times.

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] = ...,
) types.AsyncGeneratorType[T, T | None][source]
asyncutils.iters.aonline_sorter(
it: asyncutils._internal.prots.SupportsIteration[T],
key: None = ...,
reverse: bool = ...,
*,
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[T, T | None]
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],
) types.AsyncGeneratorType[T, T | None]
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).
If reverse is True, emit items in descending order.
The return value of key is awaited iff await_key=True is passed. If key is None (the default), the items themselves are compared.
Items cannot be None, because for an async generator agen, agen.asend(None) and anext(agen) are indistinguishable.
If it is 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,
) types.AsyncGeneratorType[list[V]][source]
asyncutils.iters.apadded[T](
it: asyncutils._internal.prots.SupportsIteration[T],
fillvalue: T,
n: int | None = ...,
) types.AsyncGeneratorType[T][source]

Yield the items in the (async) iterable it, followed by fillvalue repeatedly, such that the iterable is fully consumed and the result has length at least n if passed.

asyncutils.iters.apadnone[T](
it: asyncutils._internal.prots.SupportsIteration[T],
n: int | None = ...,
) types.AsyncGeneratorType[T | None][source]

Yield the items in the (async) iterable it, followed by None repeatedly, such that the iterable is fully consumed and the result has length at least n if 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],
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]][source]

Return a tuple (fg, tg). tg is an async generator yielding the items in it passing the predicate, and fg the others.

asyncutils.iters.apermutations[T](
it: asyncutils._internal.prots.SupportsIteration[T],
r: int | None = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]

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 x given 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. Yield init<<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] = ...,
) types.AsyncGeneratorType[frozenset[T]][source]
asyncutils.iters.apowerset_of_sets(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
frozen: Literal[False],
) types.AsyncGeneratorType[set[T]]

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 if frozen is True (the default) and set’s otherwise.

asyncutils.iters.aprepend[T](val: T, it: asyncutils._internal.prots.SupportsIteration[T]) types.AsyncGeneratorType[T][source]

Prepend val to the (async) iterable it.

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 start if passed.

asyncutils.iters.aproduct[T](
i1: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
repeat: Literal[1] = ...,
) types.AsyncGeneratorType[tuple[T]][source]
asyncutils.iters.aproduct(
i1: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
asyncutils.iters.aproduct(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
/,
*,
repeat: Literal[1] = ...,
) types.AsyncGeneratorType[tuple[T, R]]
asyncutils.iters.aproduct(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T | R, Ellipsis]]
asyncutils.iters.aproduct(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
i3: asyncutils._internal.prots.SupportsIteration[V],
/,
*,
repeat: Literal[1] = ...,
) types.AsyncGeneratorType[tuple[T, R, V]]
asyncutils.iters.aproduct(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
i3: asyncutils._internal.prots.SupportsIteration[V],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T | R | V, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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,
) types.AsyncGeneratorType[tuple[T | R | V | U, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
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,
) types.AsyncGeneratorType[tuple[T | R | V | U | S, Ellipsis]]
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 = ...,
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]
asyncutils.iters.aproduct(
*its: asyncutils._internal.prots.SupportsIteration[T],
repeat: int = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]

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] = ...,
) int[source]

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 r items at random from the input iterable it, without replacement.

asyncutils.iters.arandom_combination_with_replacement[T](
it: asyncutils._internal.prots.SupportsIteration[T],
r: int,
) types.AsyncGeneratorType[T][source]

Draw r items at random from the input iterable it, 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 = ...,
) types.AsyncGeneratorType[T][source]

Choose a random permutation of the elements in it of size r, or all sizes if not passed.

asyncutils.iters.arandom_product[T](*its: asyncutils._internal.prots.SupportsIteration[T], n: int = ...) types.AsyncGeneratorType[T][source]

Draw n items from each of the input iterables its at 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 range that 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 it exactly n times before advancing.

asyncutils.iters.arepeat_func[T, *Ts](
f: collections.abc.Callable[[*Ts], collections.abc.Awaitable[T]],
times: int | None = ...,
*a: *Ts,
) types.AsyncGeneratorType[T][source]

Call the async function f with arguments a repeatedly for times times, or indefinitely if times is not passed, and yield the results awaited.

asyncutils.iters.arepeat_last[T](
it: asyncutils._internal.prots.SupportsIteration[T],
default: T | asyncutils._internal.prots.Raise = ...,
) types.AsyncGeneratorType[T][source]

Yield all the items in the (async) iterable it, then keep yielding the last item forever, or default if the iterable was empty, stopping if it was not passed. If default was RAISE, raise ItemsExhausted.

asyncutils.iters.areshape[T](
mat: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[T]],
shape: int,
) types.AsyncGeneratorType[list[T]][source]
asyncutils.iters.areshape(
mat: asyncutils._internal.prots.SupportsIteration[object],
shape: asyncutils._internal.prots.SupportsIteration[int],
) types.AsyncGeneratorType[list[Any]]

Change the shape of a tensor according to shape. For an integer shape, the matrix must be 2D and shape is the number of output columns.

asyncutils.iters.areversed[T](
it: asyncutils._internal.prots.SupportsIteration[T] | collections.abc.Reversible[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), where item is an item from the input iterable and count is 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 = ...,
) types.AsyncGeneratorType[T][source]

Yield the median of all the items seen from it within a window of size maxlen, 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] = ...,
) list[T][source]

Chooses k items from an (async) iterable of items, where each item is chosen with equal probability. rrange and rand should be the randrange() and random() 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] = ...,
) list[T][source]

Choose k items from an (async) iterable of (item, weight) pairs, where the probability of each item being chosen is proportional to its weight. rrange and rand should be the randrange() and random() 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],
) types.AsyncGeneratorType[T][source]

Feed i2 into i1 and 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 = ...,
) types.AsyncGeneratorType[T][source]
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 = ...,
) types.AsyncGeneratorType[T]
Apply a side effect function f to each item in an (async) iterable it and yield the items unchanged in an async generator.
If size is specified, the side effect function is applied to batches of that size instead of individual items, but the items are still yielded separately.
The before and after functions are called before and after the iteration, respectively, but after is not called if before fails.
asyncutils.iters.asieve(n: int) types.AsyncGeneratorType[int][source]

Yield prime numbers strictly smaller than n in 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 size n, which should be of the same type as seq, from the start to the end.
If strict is True, raise ValueError if the length of any slice is less than n (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] = ...,
) list[T]
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],
) list[T]

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 = ...,
) types.AsyncGeneratorType[list[T]][source]

Split an async iterator at each item satisfying pred, with keep_sep dictating 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 = ...,
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]][source]

Return an async generator containing the first n items, 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] = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]
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],
) types.AsyncGeneratorType[tuple[T, Ellipsis]]

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] = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]
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],
) types.AsyncGeneratorType[tuple[T, Ellipsis]]

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] = ...,
) types.AsyncGeneratorType[R][source]
asyncutils.iters.astarmap(
f: collections.abc.Callable[[*Ts], collections.abc.Awaitable[R]],
it: asyncutils._internal.prots.SupportsIteration[tuple[*Ts]],
/,
await_: Literal[True],
) types.AsyncGeneratorType[R]

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]]],
/,
) types.AsyncGeneratorType[T][source]

Like amap(), but the iterable should yield tuples of the form (args, kwargs), where args is an iterable of positional arguments and kwargs is 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 = ...,
) types.AsyncGeneratorType[tuple[collections.abc.Iterable[T], int, int]]

Yield tuples of the form (substr, start, end), where substr is a contiguous subsequence of seq starting at index start and ending at index end-1 (such that its length is end-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 it as 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 start if 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],
/,
) T[source]

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],
) types.AsyncGeneratorType[T][source]
asyncutils.iters.atabulate(
f: collections.abc.Callable[[int], collections.abc.Awaitable[T]],
start: int = ...,
step: int = ...,
/,
*,
await_: Literal[True] = ...,
) types.AsyncGeneratorType[T]

Composition of amap() and acount().

asyncutils.iters.atabulate_finite[T](
f: collections.abc.Callable[[int], collections.abc.Awaitable[T]],
stop: int,
/,
*,
await_: Literal[True] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.atabulate_finite(
f: collections.abc.Callable[[int], collections.abc.Awaitable[T]],
start: int,
stop: int,
step: int = ...,
/,
*,
await_: Literal[True] = ...,
) types.AsyncGeneratorType[T]
asyncutils.iters.atabulate_finite(
f: collections.abc.Callable[[int], T],
stop: int,
/,
*,
await_: Literal[False],
) types.AsyncGeneratorType[T]
asyncutils.iters.atabulate_finite(
f: collections.abc.Callable[[int], T],
start: int,
stop: int,
step: int = ...,
/,
*,
await_: Literal[False],
) types.AsyncGeneratorType[T]
asyncutils.iters.atail[T](n: int, it: asyncutils._internal.prots.SupportsIteration[T], /) types.AsyncGeneratorType[T][source]

Yield the last n items from the (async) iterable it.

asyncutils.iters.atakeuntil[T](
pred: collections.abc.Callable[[T], object] | None,
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.atakeuntil(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]

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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.atakeuntil_inclusive(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]

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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.atakewhile(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]

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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.atakewhile_inclusive(
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
it: asyncutils._internal.prots.SupportsIteration[T],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]

Like atakewhile() but stops only after yielding the first falsy item.

asyncutils.iters.atranspose[T](
mat: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsIteration[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 = ...,
) types.AsyncGeneratorType[T][source]

Yield unique elements from it in sorted order, according to key, which should not be too expensive. If reverse is True, 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],
) types.AsyncGeneratorType[T]
asyncutils.iters.aunique_everseen(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], object],
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[T]

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],
) types.AsyncGeneratorType[T]
asyncutils.iters.aunique_justseen(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], object],
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[T]

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 = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T]][source]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R]],
*,
put_batch: int = ...,
fillvalue: R,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T]]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[T, S]],
*,
put_batch: int = ...,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T], asyncutils._internal.prots.AUnzipConsumer[S]]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R, S | R]],
*,
put_batch: int = ...,
fillvalue: R,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T], asyncutils._internal.prots.AUnzipConsumer[S]]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[T, S, V]],
*,
put_batch: int = ...,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T], asyncutils._internal.prots.AUnzipConsumer[S], asyncutils._internal.prots.AUnzipConsumer[V]]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R, S | R, V | R]],
*,
put_batch: int = ...,
fillvalue: R,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T], asyncutils._internal.prots.AUnzipConsumer[S], asyncutils._internal.prots.AUnzipConsumer[V]]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[T, S, V, U]],
*,
put_batch: int = ...,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T], asyncutils._internal.prots.AUnzipConsumer[S], asyncutils._internal.prots.AUnzipConsumer[V], asyncutils._internal.prots.AUnzipConsumer[U]]
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 = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T], asyncutils._internal.prots.AUnzipConsumer[S], asyncutils._internal.prots.AUnzipConsumer[V], asyncutils._internal.prots.AUnzipConsumer[U]]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[T, Ellipsis]],
*,
put_batch: int = ...,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T], Ellipsis]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[T | R, Ellipsis]],
*,
put_batch: int = ...,
fillvalue: R,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[T], Ellipsis]
async asyncutils.iters.aunzip(
ait: asyncutils._internal.prots.SupportsIteration[tuple[Any, Ellipsis]],
*,
put_batch: int = ...,
fillvalue: object = ...,
maxqsize: int = ...,
) tuple[asyncutils._internal.prots.AUnzipConsumer[Any], Ellipsis]
Undo the effect of zip, itertools.zip_longest(), aziplongest() or azip().
This function operates lazily, consuming items from the async iterable only when needed, in batches of size put_batch (default AUNZIP_DEFAULT_PUT_BATCH) and caching other items in queues of capacity maxqsize (default AUNZIP_DEFAULT_MAX_QSIZE).

Warning

This function may require significant auxiliary space.

asyncutils.iters.awindowed_complete[T](
it: asyncutils._internal.prots.SupportsIteration[T],
n: int,
) types.AsyncGeneratorType[tuple[tuple[T, Ellipsis], tuple[T, Ellipsis], tuple[T, Ellipsis]]][source]

Yield tuples of the form (prev, window, next), where window is a tuple of n items from the (async) iterable it, and prev and next are 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 it by yielding start first, then the items in it, then end.

asyncutils.iters.awrapf[T](
it: asyncutils._internal.prots.SupportsIteration[T],
before: collections.abc.Callable[[], object],
after: None = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.awrapf(
it: asyncutils._internal.prots.SupportsIteration[T],
before: None,
after: collections.abc.Callable[[], object],
) types.AsyncGeneratorType[T]
asyncutils.iters.awrapf(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
after: collections.abc.Callable[[], object],
) types.AsyncGeneratorType[T]
asyncutils.iters.awrapf(
it: asyncutils._internal.prots.SupportsIteration[T],
before: collections.abc.Callable[[], object],
after: collections.abc.Callable[[], object],
) types.AsyncGeneratorType[T]

Call before when the iterable starts, then yield the items in it, then call after as long as before did not raise and the iterable was converted to an async generator successfully. The return value of each function is awaited if it doesn’t raise TypeError.

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],
/,
) types.AsyncGeneratorType[tuple[T, R]]
asyncutils.iters.azip(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
/,
*,
strict: Literal[True],
) types.AsyncGeneratorType[tuple[T, R]]
asyncutils.iters.azip(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
i3: asyncutils._internal.prots.SupportsIteration[V],
/,
) types.AsyncGeneratorType[tuple[T, R, 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],
) types.AsyncGeneratorType[tuple[T, R, V]]
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],
/,
) types.AsyncGeneratorType[tuple[T, R, V, 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],
) types.AsyncGeneratorType[tuple[T, R, V, 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],
i5: asyncutils._internal.prots.SupportsIteration[S],
/,
) types.AsyncGeneratorType[tuple[T, R, V, U, 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],
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
asyncutils.iters.azip(
*its: asyncutils._internal.prots.SupportsIteration[T],
strict: bool = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]

Async version of zip that 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 = ...,
) types.AsyncGeneratorType[tuple[T | None]][source]
asyncutils.iters.azip_offset(
it: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
longest: bool = ...,
fillvalue: R,
) types.AsyncGeneratorType[tuple[T | 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 = ...,
) types.AsyncGeneratorType[tuple[T | None, R | 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,
) types.AsyncGeneratorType[tuple[T | V, R | 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 = ...,
) types.AsyncGeneratorType[tuple[T | None, R | None, V | 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,
) types.AsyncGeneratorType[tuple[T | U, R | U, V | 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 = ...,
) types.AsyncGeneratorType[tuple[T | None, R | None, V | None, U | 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,
) types.AsyncGeneratorType[tuple[T | S, R | S, V | S, U | 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 = ...,
) types.AsyncGeneratorType[tuple[T | None, R | None, V | None, U | None, S | 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 = ...,
) types.AsyncGeneratorType[tuple[T | None, Ellipsis]]
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,
) types.AsyncGeneratorType[tuple[T | R, Ellipsis]]
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 = ...,
) types.AsyncGeneratorType[tuple[T, R]]
asyncutils.iters.aziplongest(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
i3: asyncutils._internal.prots.SupportsIteration[V],
/,
*,
fillvalue: object = ...,
) types.AsyncGeneratorType[tuple[T, R, V]]
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 = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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 = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
asyncutils.iters.aziplongest(
*its: asyncutils._internal.prots.SupportsIteration[T],
fillvalue: T = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]

Async version of itertools.zip_longest() that is not a class. The first overload does not accept fillvalue, 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 n items in the (async) iterable it, 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 = ...,
) types.AsyncGeneratorType[list[T]][source]

More flexible but slightly slower implementation of batch2(), supporting timeouts waiting for each item, that raises ValueError instead of ItemsExhausted in 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],
) types.AsyncGeneratorType[list[T]][source]
asyncutils.iters.batch2(
it: asyncutils._internal.prots.SupportsIteration[T],
n: int | None,
strict: Literal[False] = ...,
) types.AsyncGeneratorType[list[T]]

Batch an (async) iterable into an async generator of lists. If strict=True is specified, raise ItemsExhausted on 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]],
) types.AsyncGeneratorType[R][source]

Apply processor to each batch of size size in items and 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 = ...,
) types.AsyncGeneratorType[T][source]
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.
cooldown specifies 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 = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]][source]
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 by copy().

asyncutils.iters.coalesce[T](
it: asyncutils._internal.prots.SupportsIteration[T],
f: collections.abc.Callable[[T, T], T | asyncutils._internal.prots.NoCoalesce],
await_: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
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],
) types.AsyncGeneratorType[T]
asyncutils.iters.counts[T](
it: asyncutils._internal.prots.SupportsIteration[T],
key: None = ...,
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[asyncutils._internal.prots.CountItem[T, T]][source]
asyncutils.iters.counts(
it: asyncutils._internal.prots.SupportsIteration[T],
key: None = ...,
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[asyncutils._internal.prots.CountItem[T, T]]
asyncutils.iters.counts(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], R],
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[asyncutils._internal.prots.CountItem[T, R]]
asyncutils.iters.counts(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
await_key: Literal[True],
) types.AsyncGeneratorType[asyncutils._internal.prots.CountItem[T, R]]
asyncutils.iters.decreasing_runs[T: asyncutils._internal.prots.SupportsRichComparison](
it: asyncutils._internal.prots.SupportsIteration[T],
typ: type[T] | None = ...,
max_runs: int = ...,
) types.AsyncGeneratorType[list[T]][source]
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] = ...,
) FirstMisMatch[T, R] | Shorter[T] | Longer[R] | None[source]
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],
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]]
asyncutils.iters.distribute(
n: Literal[3],
it: asyncutils._internal.prots.SupportsIteration[T],
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]]
asyncutils.iters.distribute(
n: Literal[4],
it: asyncutils._internal.prots.SupportsIteration[T],
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]]
asyncutils.iters.distribute(
n: Literal[5],
it: asyncutils._internal.prots.SupportsIteration[T],
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.duplicates(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], collections.abc.Hashable],
*,
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[T]
asyncutils.iters.duplicates(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], collections.abc.Awaitable[collections.abc.Hashable]],
*,
await_key: Literal[True],
) types.AsyncGeneratorType[T]
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 = ...,
) list[asyncio.Future[T]][source]
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 Future for the fut parameter, 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],
) types.AsyncGeneratorType[T][source]
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] = ...,
) types.AsyncGeneratorType[R][source]
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] = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]
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 = ...,
) types.AsyncGeneratorType[R]

Async version of map that is not a class, with await_ 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,
) list[T][source]

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,
) types.AsyncGeneratorType[T][source]

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,
) types.AsyncGeneratorType[T][source]

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 = ...,
) types.AsyncGeneratorType[T | None][source]
asyncutils.iters.fuse(
it: asyncutils._internal.prots.SupportsIteration[T | None],
end_at: None = ...,
*,
keep_end: Literal[False] = ...,
yield_after: R,
) types.AsyncGeneratorType[T | R]
asyncutils.iters.fuse(
it: asyncutils._internal.prots.SupportsIteration[T | None],
end_at: None = ...,
*,
keep_end: Literal[True],
yield_after: R,
) types.AsyncGeneratorType[T | R | None]
asyncutils.iters.fuse(
it: asyncutils._internal.prots.SupportsIteration[T | R],
end_at: R,
*,
keep_end: bool = ...,
) types.AsyncGeneratorType[T | R]
asyncutils.iters.fuse(
it: asyncutils._internal.prots.SupportsIteration[T | R],
end_at: R,
*,
keep_end: Literal[False] = ...,
yield_after: V,
) types.AsyncGeneratorType[T | V]
asyncutils.iters.fuse(
it: asyncutils._internal.prots.SupportsIteration[T | R],
end_at: R,
*,
keep_end: Literal[True],
yield_after: V,
) types.AsyncGeneratorType[T | R | V]
asyncutils.iters.gray_product[T](
i1: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
repeat: Literal[1] = ...,
) types.AsyncGeneratorType[tuple[T]][source]
asyncutils.iters.gray_product(
i1: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
asyncutils.iters.gray_product(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
/,
*,
repeat: Literal[1] = ...,
) types.AsyncGeneratorType[tuple[T, R]]
asyncutils.iters.gray_product(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T | R, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V]]
asyncutils.iters.gray_product(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
i3: asyncutils._internal.prots.SupportsIteration[V],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T | R | V, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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,
) types.AsyncGeneratorType[tuple[T | R | V | U, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
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,
) types.AsyncGeneratorType[tuple[T | R | V | U | S, Ellipsis]]
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 = ...,
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]
asyncutils.iters.gray_product(
*its: asyncutils._internal.prots.SupportsIteration[T],
repeat: int = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
asyncutils.iters.group_from[T, R](
keys: asyncutils._internal.prots.SupportsIteration[T],
values: asyncutils._internal.prots.SupportsIteration[R],
strict: bool = ...,
) types.AsyncGeneratorType[tuple[T, types.AsyncGeneratorType[R]]][source]

Yield tuples of the form (key, group), where group is an async generator taken from values and corresponding to the same run of keys in keys. If strict=False is passed, an error is not raised when keys and values differ 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] = ...,
) int[source]

Return the Hamming distance between two (async) iterables, using cmpeq to 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 = ...,
) types.AsyncGeneratorType[list[T]][source]
async asyncutils.iters.is_sorted(
it: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.SupportsRichComparison],
key: None = ...,
reverse: bool = ...,
strict: bool = ...,
*,
await_key: Literal[False] = ...,
) bool[source]
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] = ...,
) bool
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],
) bool
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 summaryf on the passed (async) iterable and returns the time taken to run it. By default, summaryf consumes it fully.

asyncutils.iters.iterate_with_key[T](
it: asyncutils._internal.prots.SupportsIteration[T],
key: None = ...,
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[T, T]][source]
asyncutils.iters.iterate_with_key(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], R],
await_key: Literal[False] = ...,
) types.AsyncGeneratorType[tuple[R, T]]
asyncutils.iters.iterate_with_key(
it: asyncutils._internal.prots.SupportsIteration[T],
key: collections.abc.Callable[[T], collections.abc.Awaitable[R]],
await_key: Literal[True],
) types.AsyncGeneratorType[tuple[R, T]]
asyncutils.iters.locate[T](
it: asyncutils._internal.prots.SupportsIteration[T],
pred: collections.abc.Callable[[T], object] = ...,
window_size: None = ...,
*,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[int][source]
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],
) types.AsyncGeneratorType[int]
asyncutils.iters.locate(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
window_size: int,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[int]
asyncutils.iters.locate(
it: asyncutils._internal.prots.SupportsIteration[T],
pred: collections.abc.Callable[[T], object],
window_size: int,
*,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[int]
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],
) types.AsyncGeneratorType[int]
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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.lstrip(
it: asyncutils._internal.prots.SupportsIteration[T],
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]
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] = ...,
) types.AsyncGeneratorType[T][source]
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] = ...,
) types.AsyncGeneratorType[T]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[T]
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] = ...,
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[T]
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],
) types.AsyncGeneratorType[T]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[T]
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],
) types.AsyncGeneratorType[R]
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] = ...,
) types.AsyncGeneratorType[tuple[V, Ellipsis]][source]
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],
) types.AsyncGeneratorType[tuple[V, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[V, Ellipsis]]
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],
) types.AsyncGeneratorType[tuple[V, Ellipsis]]

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] = ...,
) types.AsyncGeneratorType[R][source]
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] = ...,
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[R]
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],
) types.AsyncGeneratorType[int][source]

Multiplication of a matrix M and a vector V. O(n^2).

asyncutils.iters.merge[T](
*I: asyncutils._internal.prots.SupportsIteration[T],
reverse: bool = ...,
maxqsize: int = ...,
) types.AsyncGeneratorType[T][source]
Merge items from the (async) iterables into a single async generator, according to the order in which they come.
If reverse is True, the order is reversed, but the returned generator only starts when all items are available.
maxqsize (default MERGE_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 maxqsize is 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] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.pad_using(
it: asyncutils._internal.prots.SupportsIteration[T],
f: collections.abc.Callable[[int], T],
size: int | None = ...,
*,
await_: Literal[False],
) types.AsyncGeneratorType[T]
asyncutils.iters.partial_product[T](
i1: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
repeat: Literal[1] = ...,
) types.AsyncGeneratorType[tuple[T]][source]
asyncutils.iters.partial_product(
i1: asyncutils._internal.prots.SupportsIteration[T],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
asyncutils.iters.partial_product(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
/,
*,
repeat: Literal[1] = ...,
) types.AsyncGeneratorType[tuple[T, R]]
asyncutils.iters.partial_product(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T | R, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V]]
asyncutils.iters.partial_product(
i1: asyncutils._internal.prots.SupportsIteration[T],
i2: asyncutils._internal.prots.SupportsIteration[R],
i3: asyncutils._internal.prots.SupportsIteration[V],
/,
*,
repeat: int,
) types.AsyncGeneratorType[tuple[T | R | V, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U]]
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,
) types.AsyncGeneratorType[tuple[T | R | V | U, Ellipsis]]
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] = ...,
) types.AsyncGeneratorType[tuple[T, R, V, U, S]]
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,
) types.AsyncGeneratorType[tuple[T | R | V | U | S, Ellipsis]]
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 = ...,
) types.AsyncGeneratorType[tuple[Any, Ellipsis]]
asyncutils.iters.partial_product(
*its: asyncutils._internal.prots.SupportsIteration[T],
repeat: int = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis]]
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 = ...,
) int
asyncutils.iters.rstrip[T](
it: asyncutils._internal.prots.SupportsIteration[T],
pred: collections.abc.Callable[[T], object] | None = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.rstrip(
it: asyncutils._internal.prots.SupportsIteration[T],
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]
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] = ...,
) types.AsyncGeneratorType[V][source]
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],
) types.AsyncGeneratorType[V]
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] = ...,
) types.AsyncGeneratorType[V]
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],
) types.AsyncGeneratorType[V]
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] = ...,
) types.AsyncGeneratorType[V]
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],
) types.AsyncGeneratorType[V]
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] = ...,
) types.AsyncGeneratorType[V]
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],
) types.AsyncGeneratorType[V]
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] = ...,
) list[tuple[T, Ellipsis]][source]
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] = ...,
) list[tuple[T, Ellipsis]]
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] = ...,
) list[tuple[T, Ellipsis]]
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],
) list[tuple[T, Ellipsis]]
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],
) list[tuple[T, Ellipsis]]
asyncutils.iters.split_when[T](
it: asyncutils._internal.prots.SupportsIteration[T],
pred: collections.abc.Callable[[T, T], object],
maxsplit: int = ...,
) types.AsyncGeneratorType[list[T]][source]
asyncutils.iters.stagger[T](
it: asyncutils._internal.prots.SupportsIteration[T],
*,
longest: Literal[False] = ...,
fillvalue: None = ...,
) types.AsyncGeneratorType[tuple[T | None, T, T]][source]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
longest: Literal[False] = ...,
fillvalue: R,
) types.AsyncGeneratorType[tuple[T | R, T, T]]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
longest: Literal[True],
fillvalue: None = ...,
) types.AsyncGeneratorType[tuple[T | None, T | None, T | None]]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
*,
longest: Literal[True],
fillvalue: R,
) types.AsyncGeneratorType[tuple[T | R, T | R, T | R]]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
offsets: tuple[asyncutils._internal.prots.IntCompatible],
*,
longest: bool = ...,
fillvalue: None = ...,
) types.AsyncGeneratorType[tuple[T | None]]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
offsets: tuple[asyncutils._internal.prots.IntCompatible],
*,
longest: bool = ...,
fillvalue: R,
) types.AsyncGeneratorType[tuple[T | R]]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
offsets: tuple[asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible],
*,
longest: bool = ...,
fillvalue: None = ...,
) types.AsyncGeneratorType[tuple[T | None, T | None]]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
offsets: tuple[asyncutils._internal.prots.IntCompatible, asyncutils._internal.prots.IntCompatible],
*,
longest: bool = ...,
fillvalue: R,
) types.AsyncGeneratorType[tuple[T | R, T | 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 = ...,
) types.AsyncGeneratorType[tuple[T | None, T | None, T | 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,
) types.AsyncGeneratorType[tuple[T | R, T | R, T | 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 = ...,
) types.AsyncGeneratorType[tuple[T | None, T | None, T | None, T | 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,
) types.AsyncGeneratorType[tuple[T | R, T | R, T | R, T | R]]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
*,
longest: bool = ...,
fillvalue: None = ...,
) types.AsyncGeneratorType[tuple[T | None, Ellipsis]]
asyncutils.iters.stagger(
it: asyncutils._internal.prots.SupportsIteration[T],
offsets: asyncutils._internal.prots.SupportsIteration[asyncutils._internal.prots.IntCompatible],
*,
longest: bool = ...,
fillvalue: R,
) types.AsyncGeneratorType[tuple[T | R, Ellipsis]]
asyncutils.iters.strip[T](
it: asyncutils._internal.prots.SupportsIteration[T],
pred: collections.abc.Callable[[T], object] | None = ...,
await_pred: Literal[False] = ...,
) types.AsyncGeneratorType[T][source]
asyncutils.iters.strip(
it: asyncutils._internal.prots.SupportsIteration[T],
pred: collections.abc.Callable[[T], collections.abc.Awaitable[object]],
await_pred: Literal[True],
) types.AsyncGeneratorType[T]
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 = ...,
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]]
asyncutils.iters.tee(
it: asyncutils._internal.prots.SupportsIteration[T],
n: Literal[3],
*,
maxqsize: int = ...,
put_exc: bool = ...,
loop: asyncio.AbstractEventLoop | None = ...,
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]]
asyncutils.iters.tee(
it: asyncutils._internal.prots.SupportsIteration[T],
n: Literal[4],
*,
maxqsize: int = ...,
put_exc: bool = ...,
loop: asyncio.AbstractEventLoop | None = ...,
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]]
asyncutils.iters.tee(
it: asyncutils._internal.prots.SupportsIteration[T],
n: Literal[5],
*,
maxqsize: int = ...,
put_exc: bool = ...,
loop: asyncio.AbstractEventLoop | None = ...,
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]]
asyncutils.iters.tee(
it: asyncutils._internal.prots.SupportsIteration[T],
n: Literal[6],
*,
maxqsize: int = ...,
put_exc: bool = ...,
loop: asyncio.AbstractEventLoop | None = ...,
) tuple[types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T], types.AsyncGeneratorType[T]]
asyncutils.iters.tee(
it: asyncutils._internal.prots.SupportsIteration[T],
n: int,
*,
maxqsize: int = ...,
put_exc: bool = ...,
loop: asyncio.AbstractEventLoop | None = ...,
) tuple[types.AsyncGeneratorType[T], Ellipsis]
Create n independent async generators from a single (async) iterable it that yield the same items, caching items in a queue when needed.
A background task is spawned to consume the iterable.
Unlike itertools.tee(), the returned iterators are plain async generators, and the flattening step with a linked list as specified in the itertools docs is not done.
maxqsize (default TEE_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.
If put_exc is True (default TEE_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, and QueueShutDown will 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 it into a deque.

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 it into a set or frozenset depending on the frozen parameter (False by 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 = ...,
) bool[source]

Whether the vectors u and v are equal according to cmpeq called on each pair of items from iterating through them in parallel. If strict is False (default True), may return True even for differently-sized vectors.

asyncutils.iters.window[T](
it: asyncutils._internal.prots.SupportsIteration[T],
size: int,
step: int = ...,
) types.AsyncGeneratorType[tuple[T, Ellipsis], tuple[int, int] | None][source]

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.