Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/more-itertools/more-itertools
More routines for operating on iterables, beyond itertools
https://github.com/more-itertools/more-itertools
Last synced: 10 days ago
JSON representation
More routines for operating on iterables, beyond itertools
- Host: GitHub
- URL: https://github.com/more-itertools/more-itertools
- Owner: more-itertools
- License: mit
- Created: 2012-04-26T05:15:14.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T17:50:17.000Z (7 months ago)
- Last Synced: 2024-04-13T21:43:22.051Z (7 months ago)
- Language: Python
- Homepage: https://more-itertools.rtfd.io
- Size: 1.87 MB
- Stars: 3,416
- Watchers: 41
- Forks: 264
- Open Issues: 17
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- best-of-python - GitHub - 7% open · ⏱️ 02.06.2024): (General Utilities)
- awesome-python-resources - GitHub - 6% open · ⏱️ 10.08.2022): (函数式编程)
- awesome-list - More Itertools - More routines for operating on iterables, beyond itertools. (Containers & Language Extentions & Linting / For Python)
README
==============
More Itertools
==============.. image:: https://readthedocs.org/projects/more-itertools/badge/?version=latest
:target: https://more-itertools.readthedocs.io/en/stable/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.+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grouping | `chunked `_, |
| | `ichunked `_, |
| | `chunked_even `_, |
| | `sliced `_, |
| | `constrained_batches `_, |
| | `distribute `_, |
| | `divide `_, |
| | `split_at `_, |
| | `split_before `_, |
| | `split_after `_, |
| | `split_into `_, |
| | `split_when `_, |
| | `bucket `_, |
| | `unzip `_, |
| | `batched `_, |
| | `grouper `_, |
| | `partition `_, |
| | `transpose `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Lookahead and lookback | `spy `_, |
| | `peekable `_, |
| | `seekable `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Windowing | `windowed `_, |
| | `substrings `_, |
| | `substrings_indexes `_, |
| | `stagger `_, |
| | `windowed_complete `_, |
| | `pairwise `_, |
| | `triplewise `_, |
| | `sliding_window `_, |
| | `subslices `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Augmenting | `count_cycle `_, |
| | `intersperse `_, |
| | `padded `_, |
| | `repeat_each `_, |
| | `mark_ends `_, |
| | `repeat_last `_, |
| | `adjacent `_, |
| | `groupby_transform `_, |
| | `pad_none `_, |
| | `ncycles `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Combining | `collapse `_, |
| | `sort_together `_, |
| | `interleave `_, |
| | `interleave_longest `_, |
| | `interleave_evenly `_, |
| | `zip_offset `_, |
| | `zip_equal `_, |
| | `zip_broadcast `_, |
| | `flatten `_, |
| | `roundrobin `_, |
| | `prepend `_, |
| | `value_chain `_, |
| | `partial_product `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Summarizing | `ilen `_, |
| | `unique_to_each `_, |
| | `sample `_, |
| | `consecutive_groups `_, |
| | `run_length `_, |
| | `map_reduce `_, |
| | `join_mappings `_, |
| | `exactly_n `_, |
| | `is_sorted `_, |
| | `all_equal `_, |
| | `all_unique `_, |
| | `minmax `_, |
| | `first_true `_, |
| | `quantify `_, |
| | `iequals `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Selecting | `islice_extended `_, |
| | `first `_, |
| | `last `_, |
| | `one `_, |
| | `only `_, |
| | `strictly_n `_, |
| | `strip `_, |
| | `lstrip `_, |
| | `rstrip `_, |
| | `filter_except `_, |
| | `map_except `_, |
| | `filter_map `_, |
| | `iter_suppress `_, |
| | `nth_or_last `_, |
| | `unique_in_window `_, |
| | `before_and_after `_, |
| | `nth `_, |
| | `take `_, |
| | `tail `_, |
| | `unique_everseen `_, |
| | `unique_justseen `_, |
| | `unique `_, |
| | `duplicates_everseen `_, |
| | `duplicates_justseen `_, |
| | `classify_unique `_, |
| | `longest_common_prefix `_, |
| | `takewhile_inclusive `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Math | `dft `_, |
| | `idft `_, |
| | `convolve `_, |
| | `dotproduct `_, |
| | `factor `_, |
| | `matmul `_, |
| | `polynomial_from_roots `_, |
| | `polynomial_derivative `_, |
| | `polynomial_eval `_, |
| | `sieve `_, |
| | `sum_of_squares `_, |
| | `totient `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Combinatorics | `distinct_permutations `_, |
| | `distinct_combinations `_, |
| | `circular_shifts `_, |
| | `partitions `_, |
| | `set_partitions `_, |
| | `product_index `_, |
| | `combination_index `_, |
| | `permutation_index `_, |
| | `combination_with_replacement_index `_, |
| | `gray_product `_, |
| | `outer_product `_, |
| | `powerset `_, |
| | `powerset_of_sets `_, |
| | `random_product `_, |
| | `random_permutation `_, |
| | `random_combination `_, |
| | `random_combination_with_replacement `_, |
| | `nth_product `_, |
| | `nth_permutation `_, |
| | `nth_combination `_, |
| | `nth_combination_with_replacement `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Wrapping | `always_iterable `_, |
| | `always_reversible `_, |
| | `countable `_, |
| | `consumer `_, |
| | `with_iter `_, |
| | `iter_except `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Others | `locate `_, |
| | `rlocate `_, |
| | `replace `_, |
| | `numeric_range `_, |
| | `side_effect `_, |
| | `iterate `_, |
| | `difference `_, |
| | `make_decorator `_, |
| | `SequenceView `_, |
| | `time_limited `_, |
| | `map_if `_, |
| | `iter_index `_, |
| | `consume `_, |
| | `tabulate `_, |
| | `repeatfunc `_, |
| | `reshape `_ |
| | `doublestarmap `_ |
+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+Getting started
===============To get started, install the library with `pip `_:
.. code-block:: shell
pip install more-itertools
The recipes from the `itertools docs `_
are included in the top-level package:.. code-block:: python
>>> from more_itertools import flatten
>>> iterable = [(0, 1), (2, 3)]
>>> list(flatten(iterable))
[0, 1, 2, 3]Several new recipes are available as well:
.. code-block:: python
>>> from more_itertools import chunked
>>> iterable = [0, 1, 2, 3, 4, 5, 6, 7, 8]
>>> list(chunked(iterable, 3))
[[0, 1, 2], [3, 4, 5], [6, 7, 8]]>>> from more_itertools import spy
>>> iterable = (x * x for x in range(1, 6))
>>> head, iterable = spy(iterable, n=3)
>>> list(head)
[1, 4, 9]
>>> list(iterable)
[1, 4, 9, 16, 25]For the full listing of functions, see the `API documentation `_.
Links elsewhere
===============Blog posts about ``more-itertools``:
* `Yo, I heard you like decorators `__
* `Tour of Python Itertools `__ (`Alternate `__)
* `Real-World Python More Itertools `_Development
===========``more-itertools`` is maintained by `@erikrose `_
and `@bbayles `_, with help from `many others `_.
If you have a problem or suggestion, please file a bug or pull request in this
repository. Thanks for contributing!Version History
===============The version history can be found in `documentation `_.