Re: [Python-ideas] a memory-efficient variant of itertools.tee

2017-05-29 Thread Stephan Houben
Hi Franklin, Thanks. I should have tested with a larger sequence. I suppose delaying deletion by a bounded amount of objects is fine. I was concerned that a potentially unbounded amount of objects was kept. The "reference implementation" in the docs suggested that and my initial testing seemed t

Re: [Python-ideas] a memory-efficient variant of itertools.tee

2017-05-27 Thread Franklin? Lee
On Fri, May 26, 2017 at 2:45 PM, Stephan Houben wrote: > 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

[Python-ideas] a memory-efficient variant of itertools.tee

2017-05-26 Thread Stephan Houben
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,