Potentially breaking changes
- Python 3.9 support was dropped, since it went EOL on 2025-10-31
callback_iteris deprecated. It will be removed in a future major release.iequalsno longer returnsTruewhen called with([], [ANY])(thanks to rhettinger and pochmann3)- The
predargument forlocateandreplacemust now be able to
handle a variable number of arguments. See their docstrings for details. (thanks to veeceey, james-wasson, and pochmann3) unique_everseennow raisesTypeErrorwhen input elements are not hashable.
The silent fallback mechanism for unhashable inputs has been removed. (thanks to rhettinger and karlicoss)windowednow raisesValueErrorwhen given a window size of0(thanks to rhettinger and brevzin)- Parameter names for
flatten,iter_except,repeatfunc,prepend,transpose,
andsum_of_squareshave been changed. Code that uses these functions will need to be updated if it
uses keywords for positional arguments. (thanks to rhettinger)
New functions
concurrent_tee: similar totee, but with guaranteed threading
semantics (thanks to rhettinger)random_derangement: returns a random derangement of elements from an
iterable (thanks to rhettinger)running_mean: yields the mean of values in an iterable, or in a sliding
window (thanks to rhettinger)running_statistics: provides statistics for the values in an iterable, or
in a sliding window (thanks to rhettinger)serialize: wraps a non-concurrent iterator with a lock to enforce
sequential access (thanks to rhettinger)synchronized: wraps an iterator-returning callable to make its iterators
thread-safe (thanks to rhettinger)sized_iterator: wraps an iterable with a known length and implements__len__(thanks to assaf127)
Changes to existing functions
- The type hints for
always_iterablewere improved (thanks to rhettinger and maltevesper) - A potential bug in
callback_iterwas fixed - A bug in
exactly_n's handling of negative arguments was fixed (thanks to rhettinger) extract`` now accepts amonotonic` argument for improved performance (thanks to rhettinger)- A bug in
numeric_range's handling of negative steps was fixed (thanks to bysiber) grouperimplementation was updated to match theitertoolsdocs (thanks to rhettinger)nth_product,product_index,gray_product,
partial_product,nth_product,product_index, and
random_productnow accept arepeatkeyword argument (thanks to rhettinger)powerset_of_setscan now constructfrozensetinstances (thanks to rhettinger)- The type hints for
staggerwere improved (thanks to nathanjmcdougall) - Memory efficiency was improved for
partitionwas improved (thanks to rhettinger and yueyinqiu) - Performance for the functions
count_cycle,difference,
random_product, was improvednth_combination,nth_combination_with_replacement,
nth_permuwas improvedtation,nth_product,product_index,
random_permutation,substrings, andvalue_chainwas
improved (thanks to rhettinger) - Performance for
ichunkedwas improved (thanks to pochmann3 and rhettinger)
Other changes
- The docstrings for several functions were improved (thanks to nathanjmcdougall, olliemath, r266-tech, and rhettinger)