[Python-3000] Delayed reference counting idea

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Sep 19 16:42:18 CEST 2006


Barry Warsaw <barry at python.org> writes:

> What worries me is the unpredictability of gc vs. refcounting.  For
> some class of Python applications it's important that when an object
> is dereferenced it really goes away right then.  I /like/ reference
> counting!

This can be solved by explicit freeing of objects whose cleanup must
be performed deterministically.

Lisp has UNWIND-PROTECT and type-specific macros like WITH-OPEN-FILE.
C# has 'using' keyword. Python has 'with' which can be used for that.

Reference counting is inefficient, doesn't by itself handle cycles,
and is impractical to combine with threads which run in parallel. The
general consensus of modern language implementations is that a tracing
GC is the future.

I admit that implementing a good GC is hard. It's quite hard to make
it incremental, and it's hard to avoid stopping all threads during GC
(but it's easier to allow threads to run in parallel between GCs, with
no need of forced synchronization each time a reference to an object
is created).

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


More information about the Python-3000 mailing list