xotl.tools.future.itertools
- Functions creating iterators for efficient looping¶
-
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.New in version 1.8.4.
Changed in version 2.1.0: Based on
heapq.merge()
. In Python 3.5+, this is just an alias of it.Deprecated since version 2.1.0: Use
heapq.merge()
directly. This function will be removed when we support for Python 3.4.
-
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.
Deprecated since version 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.
Deprecated since version 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 exampleislice()
ortakewhile()
). If not specified, fillvalue defaults to None.This function is actually an alias to
itertools.izip_longest()
in Python 2.7, and an alias toitertools.zip_longest()
in Python 3.3.