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

> From: "Greg Ewing" <[EMAIL PROTECTED]>
>> 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.
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to