useless destructors

David Turner dkturner at
Tue Jun 22 18:37:38 CEST 2004

Marcin 'Qrczak' Kowalczyk <qrczak at> wrote in message news:<pan.2004. at>...
> On Tue, 22 Jun 2004 02:36:24 -0700, David Turner wrote:
> > Further to the discussion from earlier titled "does python have
> > useless destructors?", I've posted a brief summary of garbage
> > collection, RAII, and the "using" clause (which is what PEP310's
> > "with" clause amounts to).  The post is here:
> > 
> >
> You left "for later" a point which makes the last proposition unworkable:
> how to implement selective refcounting in a dynamically typed language?
> Will it still work if the refcounted object is referred to from a plain
> object? The only way I can imagine is to manage refcounts on each object
> passing, returning and rebinding.

To answer your second question first: no, of course it won't -- the
contained object will be destroyed only when the container is garbage
collected.  But of course, that's the behaviour you'd expect.  I don't
see it as a serious concern.

Your first point is well made.  I agree that it would be extremely
difficult to implement deterministic destruction in Python.  As you've
pointed out before, the overhead is considerable on some significant
platforms, and worst of all, it's not limited to cases where
deterministic destruction is used (although I still believe that the
additional overhead for other objects should be pretty minor).

David Turner

More information about the Python-list mailing list