On Fri, Jan 08, 2010 at 07:14:21AM +0900, Kornelius Kalnbach wrote:
> On 07.01.10 20:53, Paul Brannan wrote:
> > We disable the cycle-finding GC in python and don't write code that
> > produces cycles.
> How do you do that? I'm curious.

How do we do which part?  Disable the GC or write code that doesn't
produce cycles?  The former is easy:

import gc
gc.disable()

The latter requires good up-front design.  Good code generally avoids
cycles anyway.  If we create a cycle intentionally, we use a weak
reference.  Our C++ and Perl programmers are already used to writing
code like this, because both languages use reference counting.

(for the nitpickers, C++ doesn't use refcounting, but almost all the
libraries we use do).

(and the python language doesn't enforce refcounting either, but we are
using CPython, which does use refcounting in its current
implementation).

There are also tools available for python to detect cycles, which we try
to run before deployment.

Paul