Skip to content

Commit d0317f7

Browse files
committed
Doc: Clarify flattening and bugfix for itertools.tee in 3.13
1 parent 67fbdf2 commit d0317f7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Doc/library/itertools.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,16 +730,17 @@ loops that truncate the stream.
730730
produced by the upstream :func:`tee` call. This "flattening step"
731731
allows nested :func:`tee` calls to share the same underlying data
732732
chain and to have a single update step rather than a chain of calls.
733+
733734
.. note::
734735

735736
:func:`tee` automatically "flattens" existing tee objects,
736737
sharing the same underlying buffer instead of nesting them, to avoid
737-
performance degradation. This flattening behavior has existed since Python 3.7.
738+
performance degradation.
738739

739740
.. versionchanged:: 3.13
740-
Fixed a bug where re-teeing the first iterator did not correctly flatten
741-
the iterator chain in all cases. Previously, this could lead to unnecessary
742-
nesting and performance degradation in rare scenarios.
741+
Fixed a bug where re-teeing a tee iterator did not always return independent iterators.
742+
Previously, the first iterator in the result could be the same object as the
743+
input, causing inconsistent behavior.
743744

744745
.. doctest::
745746

0 commit comments

Comments
 (0)