[Python-3000] Delayed reference counting idea

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Sep 19 17:29:12 CEST 2006


Barry Warsaw <barry at python.org> writes:

> I don't see how that helps.  I can remove all references to the
> object but I still have to wait until gc runs to free it.  Can you
> explain your idea in more detail?

Objects which should be closed deterministically have the closing
action decoupled from the lifetime of the object. They are closed
explicitly; the object in a "closed" state doesn't take up any
sensitive resources.

> I just think that it's important to remember that there are use
> cases that reference counting solves. GC and refcounting both have
> their pros and cons.

Unfortunately it's hard to mix the two styles. Counting all reference
operations in the presence of a real GC would imply paying the costs
of both schemes together.

> I tend to think that Python's current refcounting + cyclic gc is the
> devil we know, so unless there is a clear, proven better way I'm not
> eager to change it.

They are different sets of tradeoffs; neither is universally better.
I claim that a tracing GC is usually better, or better in overall,
but it can't be proven to be better in all respects.

Changing an existing system creates more compatibility obstacles than
designing a system from scratch. I'm not convinced that it's practical
to change the Python GC now. I only wish it had a tracing GC instead.

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


More information about the Python-3000 mailing list