Python 2.0

Graham Matthews graham at sloth.math.uga.edu
Thu Jun 3 14:58:21 EDT 1999


adjih at technologist.com wrote:
:   But there will be cases where full garbage collection will be
: definitly a nuisance.
:   First, you must scan all the address space of the C code, which can be
: a problem if you're just using the Python interpreter in a library (i.e.
: don't have the ability to control or modifying the main program) ; or if
: your address space is too big (I use python for instance in a program
: that does an mmap of a 350 MB file).

a) you can turn gc off

b) I routinely use garbage collection on 1 Gig memory spaces with no
	 speed problems.

adjih at technologist.com wrote:
:   Second you kill the portability: you could use a subset of Python with
: ANSI-C alone ; but you can't make a incremental GC in ANSI-C.

Then don't use an incremental collector! Use a mark sweep collector.
I use such a thing almost every day -- written entirely in ANSI-C.

:   You'd get problems when embedding Python in unusual environments ; for
: instance if you embed Python in the Linux kernel, then the GC should
: also trace all the pages in the swap, or be rewritten specially for that
: case.

Why do you need to do any of these things?

adjih at technologist.com wrote:
:   The advantages of GC must be traded with its drawbacks:
: - advantages: reclaims cyclic structures.
: - drawbacks: non-portable, requires a special handling when linking with
: C, high complexity for decent GC (multi-thread incremental with
: finalization and support for C/C++ structures referencing Python
: structures).

The drawbacks you list are all misleading. Mark sweep collection (with
refcounts) is highly portable. Non compacting (or even partially
compacting) collectors require no special code to link with C.
Complexity of a mark sweep collector is not very high at all (registering
roots and traversing foreign objects being the main areas of
complexity). I am sure that for *some* collection schemes some of
the drawbacks you list are true, but not for all.

graham

-- 
          The fool escaped from paradise
        will look over his shoulder and cry
          Sit and chew on daffodils and
             struggle to answer why?




More information about the Python-list mailing list