[Python-Dev] reference leaks, __del__, and annotations

Tim Peters tim.peters at gmail.com
Tue Apr 4 18:01:33 CEST 2006


[Michael Hudson]
>>> And if we want to have a version of __del__ that can't reference
>>> 'self', we have it already: weakrefs with callbacks.

[Greg Ewing]
>> Does that actually work at the moment? Last I heard,
>> there was some issue with gc and weakref callbacks
>> as well. Has that been resolved?

[Michael]
> Talk about FUD.  Yes, it works, as far as I know.

I'm sure Greg has in mind this thread (which was in fact also the
thread that floated the idea of getting rid of __del__ in P3K):

    http://mail.python.org/pipermail/python-dev/2004-November/049744.html

As that said, some weakref gc semantics are pretty arbitrary now, and
it gave two patches that implemented distinct semantic variants.  A
problem is that the variant semantics also seem pretty arbitrary ;-),
and there's a dearth of compelling use cases to guide a decision.  If
someone devoted enough time to seriously trying to get rid of __del__,
I suspect compelling use cases would arise.  I never use __del__
anyway, so my motivation to spend time on it is hard to detect.


More information about the Python-Dev mailing list