more fun with iterators (mux, demux)
Raymond Hettinger
python at rcn.com
Wed Apr 8 17:58:12 EDT 2009
[Miles]
> I assume that "smallish values of n" refers to the fact that
> itertools.tee places items into every generator's internal deque,
> which islice then skips over, whereas your version places items only
> into the deque of the generator that needs it.
The pure python equivalent listed in the docs uses separate
deques for each subiterator, but the actual C implementation
of itertools.tee() only has one internal deque that is shared
by all of the sub-iterators.
Raymond
More information about the Python-list
mailing list