Module grscheller.fp.iterators

Library of iterator related functions.

Functions

def concat(*iterables: Iterable[_T]) ‑> Iterator[_T]

Sequentially concatenate multiple iterators into one.

  • performant to the standard library's itertools.chain
def exhaust(*iterables: Iterable[_T]) ‑> Iterator[_T]

Merge multiple iterator streams until all are exhausted.

def merge(*iterables: Iterable[_T], yield_partials: bool = False) ‑> Iterator[_T]

Merge multiple iterable streams until one is exhausted.

  • if yield_partials is true, yield any unmatched yielded values from the other iterables
  • this prevents data lose if any of the iterables are iterators with external references