[Python-3000] Removing __del__

Giovanni Bajo rasky at develer.com
Thu Sep 21 14:00:05 CEST 2006

Nick Coghlan wrote:

>> Unfortunately you're right... this is all too simple. The existing
>> mechanism doesn't have a problem with __del__ methods that do not
>> participate in loops. For those that DO participate in loops I
>> think it's perfectly plausible for your __del__ to receive a
>> reference to the actual object being finalized.
> Nope. If the argument to __del__ has a strong reference to the
> object, that object simply won't get finalized at all because it's
> not in an unreachable cycle.

What if the "self" passed to __del__ was instead a weakref.proxy, or a
similar wrapper object which does not give you access to the object itself
but lets you access its attributes? The object could have been already
collected for what I care, what I really need is to be able to say
"self.foo" to access what used to be a "foo" member of self. You can create
a totally different object of any type but with the same __dict__. Ok, it's
not that easy (properties, etc.), but you get the idea.

Am I missing something?
Giovanni Bajo

More information about the Python-3000 mailing list