I've been fiddling a bit with test_generators this morning, and have found 
that a stripped down version of the fibonacci test only leaks if the 
generator has a reference to a *copied* tee object.  It doesn't matter 
whether the copied tee object is the second result from tee(), or if you 
just create a single tee object and use its __copy__() method, the leak 
only occurs if the cycle is:

     geniter -> frame -> ... -> copied_tee -> tdo ---+
        ^                                            |
        |                                            |
        +--------------------------------------------+

The "..." is to indicate that the frame may reference the object directly 
as a local variable, or via a cell.  I've tried it both ways and it still 
leaks.  Replacing "copied_tee" with an uncopied tee object does *not* leak.

I have no idea what this means, although I've been staring at the relevant 
itertools code for some time now.  It doesn't appear that the traverse 
functions are skipping anything.

By the way, the above cycle will leak even if the generator is never 
iterated even once; it's quite simple to set up.  I'm testing this using 
-R:: on test_generators, and hacking on the _fib function and friends.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to