Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Doc/library/itertools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,17 @@ loops that truncate the stream.
allows nested :func:`tee` calls to share the same underlying data
chain and to have a single update step rather than a chain of calls.

.. note::

:func:`tee` automatically "flattens" existing tee objects,
sharing the same underlying buffer instead of nesting them, to avoid
performance degradation.

.. versionchanged:: 3.13
Fixed a bug where re-teeing a tee iterator did not always return independent iterators.
Previously, the first iterator in the result could be the same object as the
input, causing inconsistent behavior.

The flattening property makes tee iterators efficiently peekable:

.. testcode::
Expand Down
Loading