diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index aa46920d3526f0..133be4d4fd44c1 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -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::