pyrio.iterators.itertools_mixin

Classes

ItertoolsMixin

Provides integration with itertools methods. Pass corresponding parameters as kwargs

Module Contents

class pyrio.iterators.itertools_mixin.ItertoolsMixin

Provides integration with itertools methods. Pass corresponding parameters as kwargs

iterable = None
__getattr__(item)
_integrate(it_func, **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)