Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Jun 17 21:44:03 EDT 2009

On Wed, 17 Jun 2009 23:29:48 +1200, Lawrence D'Oliveiro wrote:

> In message <7x7hzbv14a.fsf at ruckus.brouhaha.com>,  wrote:
>> Lawrence D'Oliveiro <ldo at geek-central.gen.new_zealand> writes:
>>> > Reference counting is an implementation detail used by CPython but
>>> > not [implementations built on runtimes designed for
>>> > corporate-herd-oriented languages, like] IronPython or Jython.
>>> I rest my case.
>> You're really being pretty ignorant.  I don't know of any serious Lisp
>> system that uses reference counting, both for performance reasons and
>> to make sure cyclic structures are reclaimed properly.
> Both of which, oddly enough, more modern dynamic languages like Python
> manage perfectly well.

*Python* doesn't have a ref counter. That's an implementation detail of 
*CPython*. There is nothing in the specifications for the language Python 
which requires a ref counter.

CPython's ref counter is incapable of dealing with cyclic structures, and 
so it has a second garbage collector specifically for that purpose. The 
only reason Python manages perfectly well is by NOT relying on a ref 
counter: some implementations don't have one at all, and the one which 
does, uses a second gc.

Additionally, while I'm a fan of the simplicity of CPython's ref counter, 
one serious side effect of it is that it requires the GIL, which 
essentially means CPython is crippled on multi-core CPUs compared to non-
ref counting implementations.


More information about the Python-list mailing list