Created by: ptosi
What is this Python project?
From the README of the project:
Python's
itertoolslibrary is a gem - you can compose elegant solutions for a variety of problems with the functions it provides. Inmore-itertoolswe collect additional building blocks, recipes, and routines for working with Python iterables.
What's the difference between this Python project and similar ones?
more-itertools provides most re-usable functions one would want when working with iterables. By relying on this lightweight package, similarly to what itertools provide, one can write more readable and maintainable code, while avoiding having to re-invent the wheel (and introducing bugs by doing so).
As simple examples, instead of using raw iterators, one should use itertools when appropriate:
>>> from itertools import repeat
>>> (10 for _ in range(3)) # Instead of this ...
>>> repeat(10, 3) # ... use that!
and more-itertools is based on the same idea and provides many more building blocks:
>>> from more_itertools import ilen
>>> sum(1 for _ in iter) # Instead of this ...
>>> ilen(iter) # ... use that!
Of course, the project also provides more advanced expressions, hard to express as one-liners. Some of my favourites (notice their high-quality documentation):
all_equal(iterable)last(iterable[, default])nth(iterable, n, default=None)consume(iterator, n=None)distribute(n, iterable)roundrobin(*iterables)windowed(seq, n, fillvalue=None, step=1)substrings(iterable)powerset(iterable)random_permutation(iterable, r=None)with_iter(context_manager)
In many cases where I wondered "Why didn't they implement this in itertools?!", most-itertools had a single-call solution: there's a reason why the project already has 1.2k
Please give most-itertools a try and give this PR a