Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
itr: AnyIterable[T], r: int
) -> AsyncIterator[Tuple[T, ...]]:
"""
Yield r length subsequences from the given iterable with replacement.
Simple wrapper around itertools.combinations_with_replacement.
This will consume the entire iterable before yielding values.
Example:
async for value in combinations_with_replacement("ABC", 2):
... # ("A", "A"), ("A", "B"), ("A", "C"), ("B", "B"), ...
"""
pool: List[T] = await list(itr)
for value in itertools.combinations_with_replacement(pool, r):
yield value