a memory-efficient variant of itertools.tee
26 May
2017
26 May
'17
6:45 p.m.
Hi all, The itertools.tee function can hold on to objects "unnecessarily". In particular, if you do iter2 = itertools.tee(iter1, 2)[0] i.e. you "leak" one of the returned iterators, then all returned objects are not collected until also iter2 is collected. I propose a different implementation, namely the one in: https://github.com/stephanh42/streamtee streamtee.tee is a drop-in alternative for itertools.tee but as you can see from the test in the repo, it will not hold on to the generated objects as long. I propose this as an improved implementation of itertools.tee. Thanks, Stephan
2496
Age (days ago)
2499
Last active (days ago)
2 comments
2 participants
participants (2)
-
Franklin? Lee
-
Stephan Houben