Hi Neal, On Thu, Nov 24, 2005 at 07:35:06PM -0800, Neal Norwitz wrote: > The itertools.tee() fix I thought was quite obvious: > > +++ Modules/itertoolsmodule.c (working copy) > @@ -356,7 +356,8 @@ > { > if (tdo->nextlink == NULL) > tdo->nextlink = teedataobject_new(tdo->it); > - Py_INCREF(tdo->nextlink); > + else > + Py_INCREF(tdo->nextlink); > return tdo->nextlink; > }
No, if this object is saved as a cache on 'tdo' then obviously it needs to keep a reference on its own. This reference will go away in teedataobject_dealloc(). After debugging, the problem is a reference cycle: the teedataobject 'head' has a field 'it' pointing to the generator-iterator '_fib()', which has a reference back to 'head'. So what is missing is making teedataobject GC-aware, which it current isn't. I suspect that there are other itertools types in the same situation. A bientot, Armin. _______________________________________________ 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