does python have useless destructors?

Aahz aahz at pythoncraft.com
Mon Jun 14 17:14:39 CEST 2004


In article <e251b7ba.0406132319.1782460a at posting.google.com>,
David Turner <dkturner at telkomsa.net> wrote:
>Carl Banks <imbosol at aerojockey.invalid> wrote in message news:<zH0zc.89588$DG4.40492 at fe2.columbus.rr.com>...
>> David Turner wrote:
>>>
>>> Objects that define __del__ shall have a reference count, which is
>>> incremented when names are bound to the object and decremented when
>>> those names go out of scope.  The __del__ method is called when the
>>> reference count reaches zero.  This mechanism is orthogonal to garbage
>>> collection.
>> 
>> Are you aware that CPython already does this?
>
>Yes, of course.  As I pointed out elsewhere, there is a weakness in
>the current CPython implementation, in that exceptions grab extra
>references to locals for the traceback.  A relatively minor code block
>at the end of each exception handler could fix this problem.

You're far more likely to succeed in changing exception handling
semantics than general object handling semantics.  If you're serious
about fixing this hole in Python, write a PEP.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"as long as we like the same operating system, things are cool." --piranha



More information about the Python-list mailing list