Python vs Java garbage collection?

Martin v. Löwis martin at v.loewis.de
Thu Dec 26 18:00:54 EST 2002


"Martin Maney" <maney at pobox.com> writes:

> It seems to me that it would most likely be a reference count.  

But that would slow down assignments and parameter passing in
inacceptable ways, and you would also need to accomodate for the case
where Java objects hold references to Python objects.

> I take it Jython doesn't use reference counting, leaving the entire
> job to the Java runtime (with a hook to run Python finalizers, of
> course)?

Almost. I believe __del__ code is just put into a Java .finalize
method, so that they are run by the Java GC finalization.

> Perhaps it would be useful to have a way of activating ref counting
> for an object.

Now, how would you implement *that*? I.e. when activated, which
machinery precisely changes the reference count, on, say, assignment?

Also, the issue remains how to pass such objects to Java "native"
methods (i.e. pure Java methods, instead of Jython functions).

Regards,
Martin



More information about the Python-list mailing list