robot-piglet 9b7b894a85 Intermediate changes 2 месяцев назад
..
.dist-info 9b7b894a85 Intermediate changes 2 месяцев назад
more_itertools 9b7b894a85 Intermediate changes 2 месяцев назад
tests 9b7b894a85 Intermediate changes 2 месяцев назад
LICENSE e0e3e1717e add ydb deps 1 год назад
README.rst 9b7b894a85 Intermediate changes 2 месяцев назад
ya.make 9b7b894a85 Intermediate changes 2 месяцев назад

README.rst

==============
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 `_.