[Python-Dev] PEP 342/343 status?

Phillip J. Eby pje at telecommunity.com
Tue May 31 20:41:46 CEST 2005


At 11:12 AM 5/31/2005 -0700, Guido van Rossum wrote:
>uncertainty of the possibility to call close() from the
>destructor may have slowed that down.

If you're talking about the bit about __del__ not working when hanging off 
a cycle, my apologies for creating that confusion, I misunderstood Tim's post.

If you're talking about the circular reference scenario involving 
exceptions, then I think I've already given a tentative explanation why 
such a cycle will not include the generator-iterator itself (only its 
frame) as long as the generator-iterator clears its frame's f_back when the 
frame is not in use.  It would probably be a good idea to verify this, but 
I think the basic idea is sound.

The only scenario in which a generator-iterator would be uncollectable is 
if you took some action outside the iterator to pass it into itself, or if 
you stored the iterator in a global variable.  However, even in the latter 
case, the phase of Python shutdown that clears module contents would break 
the cycle and cause the generator to finalize, albeit a bit late and 
perhaps in a broken way.  Still, storage of generator-iterators in module 
globals is a very unlikely scenario, since it's more common to loop over 
such iterators than it is to store them in any kind of variable.



More information about the Python-Dev mailing list