matz at netlab.co.jp
Tue Jun 1 06:36:26 CEST 1999
Paul Prescod <paul at prescod.net> writes:
|First you say:
|> I don't get it. There's no relation between destructors and real
|> garbage collection. For example, Java uses destructors called
|> finalizers, even though most Java VM use real GC.
|But then you say:
|> I know, by ref counting, object is
|> recycled as soon as it looses last reference to it, but relying on
|> that behavior is error prone, I think.
|So you do get it. There is a relation, but you just don't think that the
|"Python way" is right, You consider the guarantees that Java gives to be
|more important than the guarantees that Python does.
Hmm, I said ``there's no relation between destructors and real GC'',
then said ``deterministic destructor invocation is not needed''.
Even though I believe Java garantees is far more important than Python
garantees as you said, that's nothing do with ``relation between
destructors and real GC''.
Remember the original statement is like this:
>As many people have noted before, you would not be able to use
>destructors to free up resources like memory or file descriptors.
which, as I understand, means destructors can not be used with real
GC. That's just not true.
|But I think that the bigger problem with "real GC" is that C programs
|often hang on to references to Python objects and any kind of compacting
|GC would invalidate those references.
It's the common legend especially here in comp.lang.python.
From my experience with Scheme and Ruby, both with real GC, the real
GC is mostly very fast. Fast enough no one notices its "hang" on most
cases. The legend was formed up by old GC implementation and slower
machines of the past, I guess.
|But note that Python's guarantees are more important in small, simple
|programs and Java's guarantees are better for large, complex programs with
|complicated data structures.
Do you really mean Python the object-oriented programming language
rarely treat complicated data structures? I think Python is good
language, good enough to make people write complex program with
complicated data structures.
I admit ref-counting is far easier to implement. But it's too simple
way for the real language like Python.
This document says ``the real GC with the finalizers do the most of
the jobs'', right?
More information about the Python-list