[Python-3000] PEP: Eliminate __del__

Michael Bayer mike_mp at zzzcomputing.com
Fri May 4 16:21:59 CEST 2007

On May 4, 2007, at 1:12 AM, Raymond Hettinger wrote:

> From: "Greg Ewing" <greg.ewing at canterbury.ac.nz>
>> It has nothing to do with cyclic GC. The point is that
>> if the refcount of a weak reference drops to zero before
>> that of the object being weakly referenced, the weak
>> reference object itself is deallocated and its callback
>> is *not* called. So having the resource-using object
>> hold the weak ref to the resource doesn't work -- it
>> has to be kept in some kind of separate registry.
> I'll write-up an idiomaticc approach an include it in PEP this  
> weekend.

why not encapsulate the "proper" weakref-based approach in an easy-to- 
use method such as "__close__()" ?  that way nobody has to guess how  
to follow this pattern.

More information about the Python-3000 mailing list