does python have useless destructors?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Jun 14 04:52:46 EDT 2004


On Mon, 14 Jun 2004 00:05:45 -0700, David Turner wrote:

> You don't need static knowledge of which names refer to deterministic
> objects.  You only need to know at three points:  when binding a name,
> when exiting a function scope, and when calling __del__ on an object.

You must manage reference counts on any parameter passing (increment),
function return (decrement refcounts of local variables), function result
(increment the refcount of the value being returned if it's a constant
or a global variable), and assignment (increment one defcount, decrement
another). Each decref is accompanied with a test for 0.

This is a high overhead. You basically impose the overhead CPython has
to all implementations, even those which already manage liveness of their
objects using a better GC scheme.

It doesn't help that only some objects must have reference counts changed,
because you statically don't know which are these, so you must check all
potential objects anyway.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/




More information about the Python-list mailing list