Python 2.0

Barry A. Warsaw bwarsaw at cnri.reston.va.us
Tue Jun 1 10:56:19 EDT 1999


>>>>> "YM" == Yukihiro Matsumoto <matz at netlab.co.jp> writes:

    YM> I don't get it.  There's no relation between destructors and
    YM> real garbage collection.  For example, Java uses destructors
    YM> called finalizers, even though most Java VM use real GC.

Interesting side-note, re finalizers and JPython.  I recall JimH
talking about finalizers during his JPython code review a few months
back.  Here's what I wrote down at the time:

    "PyInstances were 2-5x slower [than now] because __del__() was
    implemented in a finalize method.  But [current] JVMs assume most
    classes don't have a finalize [overriding Object's no-op'd
    version] and having them on everything slows frees down /a lot/
    [emphasis somebody's :) ]"

Apologies to JimH for any transcription errors!  But I think he's
correct as implied by the discussion in section 12.6 of the Java
Language Specification:

    "We encourage implementations to treat such objects [those that
    don't override Object.finalize() or do so only trivially] as
    having a finalizer that is not overridden, and to finalize them
    more efficiently."

And if you look at the diagram and discussion in section 12.6.1, you
can see why this might be so inefficient!

-Barry




More information about the Python-list mailing list