[issue16394] Improving tee() memory footprint

2012-11-03 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: -serhiy.storchaka stage: -> needs patch type: performance -> enhancement versions: -Python 2.6, Python 3.1 ___ Python tracker ___ __

[issue16394] Improving tee() memory footprint

2012-11-03 Thread Carsten Milkau
Changes by Carsten Milkau : -- assignee: -> docs@python components: +Documentation -Library (Lib) nosy: +docs@python ___ Python tracker ___ _

[issue16394] Improving tee() memory footprint

2012-11-03 Thread Carsten Milkau
Carsten Milkau added the comment: Oh great! Then I can use it as-is. How about reassigning the issue to documentation (for clarifying the inefficiency warning)? -- ___ Python tracker __

[issue16394] Improving tee() memory footprint

2012-11-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > The documentation explicitly mentions this is unfortunate. Ah, here's the thing. The code in the documentation is provided only for the explanation. In fact tee() is implemented in the same way that you suggest (but uses a more efficient deque implementa

[issue16394] Improving tee() memory footprint

2012-11-03 Thread Carsten Milkau
Carsten Milkau added the comment: No. The sample code is a demonstration how to do it, it's by no means a full-fledged patch. The drawback of the current implementation is that if you tee n-fold, and then advance one of the iterators m times, it fills n queues with m references each, for a to

[issue16394] Improving tee() memory footprint

2012-11-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Why do you think that your implementation uses less memory? You have some measurements confirming it? -- nosy: +serhiy.storchaka versions: -Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tra

[issue16394] Improving tee() memory footprint

2012-11-03 Thread Carsten Milkau
New submission from Carsten Milkau: The memory footprint of itertools.tee can be reduced substantially by using a shared buffer for the child iterators (see sample code). If local queues are desired for efficient threading support, they can be combined with a global queue, allowing to constrai