Circular references and python

Neel Krishnaswami neelk at brick.cswv.com
Thu Feb 3 19:11:47 EST 2000


James Logajan <JamesL at Lugoj.Com> wrote:
> Neel Krishnaswami wrote:
> > Apply Neil Schemenauer's patches that convinces Python to use the
> > Boehm garbage collector, or just live with the garbage, if your
> > program is relatively short-lived. You can find his patch at:
> > 
> >   http://www.acs.ucalgary.ca/~nascheme/python/gc.html
> > 
> > Manually freeing memory is ugly and error-prone. Don't do it. :)
> 
> The vast majority of code (and programming languages) in the world
> require explicit memory de-allocation. I don't believe that a GC
> scheme has yet been invented that will work well for all problem
> domains. I'm sure if it had, we'd all be using it by now. ;)

Shrug. Then you can allocate a hunk of memory and manually collect the
pieces of it, and just let the gc handle the whole hunk. You still win
on the whole.

I think a lot of people are working with severely outdated notions of
the performance of of garbage collectors. Even 16 or 17 years ago
garbage collection was expensive enough that Lisp Machiness made it
something you ran manually every few days.

But the state of the art has improved hugely: in _Compiling with
Continuations_, Andrew Appel claims that a well-tuned generational
garbage collector is competative with stack allocation in terms of
speed, for functional and OO languages. (IIRC, SML/NJ allocates even
activation records on the heap, and wins doubly because this
simplifies the runtime.)


Neel



More information about the Python-list mailing list