[Python-3000] Removing __del__
mcherm at mcherm.com
Wed Sep 20 15:24:01 CEST 2006
Nick Coghlan writes:
[...proposes revision of __del__ rather than removal...]
> The only way for __del__ to receive a reference to self is if the
> finalizer argument had a reference to it - but that would mean the
> object itself was not
> collectable, so __del__ wouldn't be called in the first place.
> That all seems too simple, though. Since we're talking about gc and
> that's never simple, there has to be something wrong with the idea :)
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.
Another problem (but less important as it's trivially fixable) is that
you're storing away the values that the object had when it was created,
perhaps missing out on things that got added or initialized later.
-- Michael Chermside
More information about the Python-3000