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