[PR #1470] [MERGED] add more-itertools #12666

Closed
opened 2026-04-27 02:06:12 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/vinta/awesome-python/pull/1470
Author: @ptosi
Created: 2/7/2020
Status: Merged
Merged: 4/7/2020
Merged by: @vinta

Base: masterHead: master


📝 Commits (1)

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 README.md (+1 -0)

📄 Description

What is this Python project?

From the README of the project:

Python's itertools library is a gem - you can compose elegant solutions for a variety of problems with the functions it provides. In more-itertools we 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):

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 on GitHub!

Please give most-itertools a try and give this PR a 👍 if you find the package useful.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/vinta/awesome-python/pull/1470 **Author:** [@ptosi](https://github.com/ptosi) **Created:** 2/7/2020 **Status:** ✅ Merged **Merged:** 4/7/2020 **Merged by:** [@vinta](https://github.com/vinta) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (1) - [`d6b358e`](https://github.com/vinta/awesome-python/commit/d6b358ea97b80c6e8fce9873e36faef1af0d85cc) add more-itertools ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+1 -0) </details> ### 📄 Description ## What is this Python project? From the README of the project: > Python's `itertools` library is a gem - you can compose elegant solutions for a variety of problems with the functions it provides. In [`more-itertools`](https://github.com/erikrose/more-itertools) we 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: ```Python >>> 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: ```Python >>> 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)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.all_equal) - [`last(iterable[, default])`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.last) - [`nth(iterable, n, default=None)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.nth) - [`consume(iterator, n=None)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.consume) - [`distribute(n, iterable)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.distribute) - [`roundrobin(*iterables)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.roundrobin) - [`windowed(seq, n, fillvalue=None, step=1)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.windowed) - [`substrings(iterable)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.substrings) - [`powerset(iterable)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.powerset) - [`random_permutation(iterable, r=None)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.random_permutation) - [`with_iter(context_manager)`](https://more-itertools.readthedocs.io/en/stable/api.html#more_itertools.with_iter) 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 :star: on GitHub! Please give `most-itertools` a try and give this PR a :+1: if you find the package useful. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-27 02:06:12 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/awesome-python#12666