Skip to content

Commit 3306fad

Browse files
restructure docs for clariy
1 parent 0c7e0dd commit 3306fad

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

asyncstdlib/itertools.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -429,23 +429,25 @@ async def derivative(sensor_data):
429429
await a.anext(previous) # advance one iterator
430430
return a.map(operator.sub, previous, current)
431431
432-
Unlike :py:func:`itertools.tee`, :py:func:`~.tee` returns a custom type instead
433-
of a :py:class:`tuple`. Like a tuple, it can be indexed, iterated and unpacked
434-
to get the child iterators. In addition, its :py:meth:`~.tee.aclose` method
435-
immediately closes all children, and it can be used in an ``async with`` context
436-
for the same effect.
432+
``tee`` must internally buffer each item until the last iterator has yielded it;
433+
if the most and least advanced iterator differ by most data,
434+
using a :py:class:`list` is more efficient (but not lazy).
437435
438436
If ``iterable`` is an iterator and read elsewhere, ``tee`` will *not*
439-
provide these items. Also, ``tee`` must internally buffer each item until the
440-
last iterator has yielded it; if the most and least advanced iterator differ
441-
by most data, using a :py:class:`list` is more efficient (but not lazy).
437+
provide these items.
442438
443439
If the underlying iterable is concurrency safe (``anext`` may be awaited
444440
concurrently) the resulting iterators are concurrency safe as well. Otherwise,
445441
the iterators are safe if there is only ever one single "most advanced" iterator.
446442
To enforce sequential use of ``anext``, provide a ``lock``
447443
- e.g. an :py:class:`asyncio.Lock` instance in an :py:mod:`asyncio` application -
448444
and access is automatically synchronised.
445+
446+
Unlike :py:func:`itertools.tee`, :py:func:`~.tee` returns a custom type instead
447+
of a :py:class:`tuple`. Like a tuple, it can be indexed, iterated and unpacked
448+
to get the child iterators. In addition, its :py:meth:`~.tee.aclose` method
449+
immediately closes all children, and it can be used in an ``async with`` context
450+
for the same effect.
449451
"""
450452

451453
__slots__ = ("_children",)

0 commit comments

Comments
 (0)