At 12:53 PM 4/17/2006 -0400, Phillip J. Eby wrote: >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.
Follow-up note: it's possible to create the same leak with this code: l = [] a, b = tee(l) l.append(b) Which -R:: reports as leaking 4 references. If you "l.append(a)" instead of 'b', there is no leaking. This showed that the problem was actually in the itertools module, as no generators are involved here. After staring at tee_copy until my eyes bled, I accidentally scrolled such that tee_new was on the screen at the same time and notice that tee_copy was missing a call to PyObject_GC_Track();. So then I fixed everything up and tried to check it in, to find that Thomas Wouters already found and fixed this yesterday. The moral of the story? Always catch up on the Python-checkins list before trying to track down cycle leaks. :) _______________________________________________ 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