[Python-3000] Is reference counting still needed?

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Apr 21 14:06:18 CEST 2006


Neil Schemenauer wrote:

> I believe that's correct.  A state of the art generational GC would
> outperform reference counting, even given Python's enormous
> allocation rate.

Another thing to consider is that Python's current scheme
tends to be more fail-safe when interacting with other
systems that don't know about the GC scheme it's using.

Most GC systems work by assuming that something is
garbage unless the system can prove that it's not.
This relies critically on being able to find all
roots that could possibly lead to an object. Miss
one anywhere and you get a very nasty crash when
something is deallocated prematurely.

Python's cyclic GC, on the other hand, assumes that
nothing is garbage unless it can prove that it is.
So if there's an object around somewhere that it
can't reach, it might leak some memory, but it won't
lead to a crash.

This is a nice property to have in something like
Python where interfacing with external code is so
important.

--
Greg


More information about the Python-3000 mailing list