Skip to content

Latest commit

 

History

History
73 lines (47 loc) · 2.87 KB

itertools.rst

File metadata and controls

73 lines (47 loc) · 2.87 KB

xotl.tools.future.itertools - Functions creating iterators for efficient looping

xotl.tools.future.itertools

merge(*iterables, key=None)

Merge the iterables in order.

Return an iterator that yields all items from iterables following the order given by key. If key is not given we compare the items.

If the iterables yield their items in increasing order (w.r.t key), the result is also ordered (like a merge sort).

merge() returns the empty iterator.

1.8.4

2.1.0 Based on heapq.merge. In Python 3.5+, this is just an alias of it.

2.1.0 Use heapq.merge directly. This function will be removed when we support for Python 3.4.

delete_duplicates(seq[, key=lambda x: x])

iter_delete_duplicates(iter[, key=lambda x: x])

iter_without_duplicates(iter[, key=lambda x: x])

flatten(sequence, is_scalar=xotl.tools.types.is_scalar, depth=None)

xotl.tools.iterators.zip([iter1[, iter2[, ...]]])

Return a zip-like object whose next() method returns a tuple where the i-th element comes from the i-th iterable argument. The next() method continues until the shortest iterable in the argument sequence is exhausted and then it raises StopIteration.

2.1.0 Use the builtin zip. This function will be removed in xotl.tools 3.

xotl.tools.iterators.map(func, *iterables)

Make an iterator that computes the function using arguments from each of the iterables. It stops when the shortest iterable is exhausted instead of filling in None for shorter iterables.

2.1.0 Use the builtin map. This function will be removed in xotl.tools 3.

xotl.tools.iterators.zip_longest(*iterables, fillvalue=None)

Make an iterator that aggregates elements from each of the iterables. If the iterables are of uneven length, missing values are filled-in with fillvalue. Iteration continues until the longest iterable is exhausted.

If one of the iterables is potentially infinite, then the zip_longest function should be wrapped with something that limits the number of calls (for example islice or takewhile). If not specified, fillvalue defaults to None.

This function is actually an alias to itertools.izip_longest in Python 2.7, and an alias to itertools.zip_longest in Python 3.3.

zip_map(funcs: Iterable[Callable[[A], B]], args: Iterable[A]) -> Iterable[B]