pyrio.iterators
Submodules
Classes
Helper class wrapping generator-based operations for lazy evaluation |
|
Provides integration with itertools methods; pass corresponding parameters as kwargs |
Package Contents
- class pyrio.iterators.StreamGenerator
Helper class wrapping generator-based operations for lazy evaluation
- static concat(*streams)
Concatenates multiple iterables into a single sequence
- static filter(iterable, predicate)
Yields elements that satisfy the predicate
- static map(iterable, mapper)
Applies mapper function to each element
- static filter_map(iterable, mapper, discard_falsy=False)
Filters out None (or falsy) values and applies mapper to remaining elements
- static flat_map(iterable, mapper)
Applies mapper and flattens the resulting iterables
- classmethod flatten(iterable)
Recursively flattens nested iterables into a single sequence
- static peek(iterable, operation)
Performs operation on each element without consuming the stream
- static iterate(seed, operation, condition=None)
Generates sequence by repeatedly applying operation to seed
- static generate(supplier)
Generates infinite sequence using supplier function
- static range(start, stop, step=1)
Yields values from start to stop with given step
- static distinct(iterable)
Yields unique elements preserving first occurrence order
- static skip(iterable, count)
Skips first n elements and yields the rest
- static limit(iterable, count)
Yields at most n elements
- static tail(iterable, count)
Yields the last n elements
- static take_while(iterable, predicate)
Yields elements while predicate is true
- static drop_while(iterable, predicate)
Skips elements while predicate is true, then yields the rest
- static sort(iterable, comparator=None, reverse=False)
Yields elements in sorted order
- static enumerate(iterable, start=0)
Yields index-element pairs starting from given index
- class pyrio.iterators.ItertoolsMixin
Provides integration with itertools methods; pass corresponding parameters as kwargs
- NO_SIGNATURE_FUNCTIONS = ['chain', 'islice', 'product', 'repeat', 'zip_longest']
- NO_KWARGS_FUNCTIONS = ['dropwhile', 'filterfalse', 'starmap', 'takewhile', 'tee']
- use(it_function, **kwargs)
Provides integration with itertools methods; pass corresponding parameters as kwargs
- _handle_no_signature_functions(it_function, **kwargs)
- _handle_no_kwargs_functions(signature, it_function, **kwargs)
- _handle_default_signature_functions(signature, it_function, **kwargs)
- tabulate(mapper, start=0)
Returns function(0), function(1), …
- repeat_func(operation, times=None)
Repeats calls to func with specified arguments
- ncycles(count=0)
Returns the stream elements n times
- consume(n=None)
Advances the iterator n-steps ahead. If n is None, consumes stream entirely
- take_nth(idx, default=None)
Returns Optional with the nth element of the stream or a default value
- all_equal(key=None)
Returns True if all elements of the stream are equal to each other
- view(start=0, stop=None, step=None)
Provides access to a selected part of the stream
- unique(key=None, reverse=False)
Yields unique elements in sorted order. Supports unhashable inputs
- static _unique(iterable, key=None)
- unique_just_seen(key=None)
Yields unique elements, preserving order. Remembers only the element just seen
- unique_ever_seen(key=None)
Yields unique elements, preserving order. Remembers all elements ever seen
- static _unique_ever_seen(iterable, key=None)
- sliding_window(n)
Collects data into overlapping fixed-length chunks or blocks
- static _sliding_window(iterable, n)
- grouper(n, *, incomplete='fill', fill_value=None)
Collects data into non-overlapping fixed-length chunks or blocks
- _grouper(n, incomplete='fill', fill_value=None)
- round_robin()
Visits input iterables in a cycle until each is exhausted
- static _round_robin(iterable)
- partition(predicate)
Partitions entries into true and false entries. Returns a stream of two nested generators
- subslices()
Returns all contiguous non-empty sub-slices
- find_indices(value, start=0, stop=None)
Returns indices where a value occurs in a sequence or iterable
- static _find_indices(iterable, value, start=0, stop=None)