Python 2.0

Paul Prescod paul at prescod.net
Tue Jun 1 10:41:37 EDT 1999


Yukihiro Matsumoto wrote:
> 
> |Is there a language with real GC where destructors are called as
> |predictably as they are in Python?
> 
> I said nothing about the destructor invocation predictability.

I consider that a part of the definition of destructor.

> I don't understand and really interested in why you guys require
> to predict destructor invocation so much, but it's another story.

What if I am holding GUI "device context" objects and the GUI has a
limited number of them. I don't think that there is a way to tell the GC
that there is a limited number of them. It doesn't know that device
contexts are a limited resource, just as memory is.

> |Speed wasn't my concern. I asked about references in C code. Do we use
> |PyObject **s instead of PyObject *s now?
> 
> Sorry, I don't understand.  Do we have to use PyObject **s instead of
> PyObject *s, if we choose real GC?

Imagine I have some C code. It stores away a pointer to a Python object:

PyObject *myObject=someObject;

Now a compacting GC moves someObject. My pointer is out of date, right? If
I want to be able to move someObject around in a mark and sweep style
operation then I need the pointer I hold to be static.

What GC algorithm does Ruby use and how much overhead does it add?

> Second, do you think that optimization for basic users compensates the
> risk of potential memory leak, by cyclic structures or missing DECREF
> in extension modules?  Do you mean it's easy for experts to find
> cyclic structure and cut their reference to destruct?  For me, it's
> not.  I hate that.  Is this because I'm not a Python expert?

It's pretty much a toss-up for me. In general I prefer optimizations that
make the language easy for new users to those that are for complex, long
running programs but full garbage collection would make complex programs a
fair bit easier.

-- 
 Paul Prescod  - ISOGEN Consulting Engineer speaking for only himself
 http://itrc.uwaterloo.ca/~papresco

"Silence," wrote Melville, "is the only Voice of God." The assertion,
like its subject, cuts both ways, negating and affirming, implying both
absence and presence, offering us a choice; it's a line that the Society
of American Atheists could put on its letterhead and the Society of
Friends could silently endorse while waiting to be moved by the spirit
to speak. - Listening for Silence by Mark Slouka, Apr. 1999, Harper's




More information about the Python-list mailing list