fork()

Andrew M. Kuchling akuchlin at mems-exchange.org
Thu Jun 10 10:10:22 EDT 1999


Guido van Rossum writes:
>(You can create a cycle using only lists, but I bet that happens only
>for demonstration purposes, as in ``a = []; a.append(a)''.  So I can
>live with not freeing such cycles.)

      I'm doubtful of that argument; I've written classes which track
all instances that get created, and this can be done with a class
attribute containing a list, that gets mutated as instances are
created.  You reconsider this decision later in your post.

	  In this solution, I don't understand how Python would keep
track of all the dictionaries that get created, in order to determine
which ones are left unreachable, and hence can be garbage collected.
>From my memory of the Jones-Lins book, this is usually handling by
doing all the allocation yourself by slicing memory into chunks, and
then sweeping through it.  It's not obvious (to me, at least) how
you'd do this with objects created by malloc().  Perhaps lists and
dictionaries could contain prev/next pointers that are used to
maintain them in a doubly-linked list, and a linear-time traversal
would be done to find unmarked objects, but there has to be a better
way.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
Should I not have changed either the day for carrying out my scheme, or the
scheme itself -- but preferably only the day?
    -- Ovid, _The Metamorphoses_




More information about the Python-list mailing list