Python vs Java garbage collection?
"Martin v. Löwis"
martin at v.loewis.de
Mon Dec 23 16:45:20 EST 2002
A. Lloyd Flanagan wrote:
> The difference between C++
> destructors and Java's finalize() or Python's __del__() is that C++
> _guarantees_ that the destructor will get called sometime before the
> program exits (barring a core dump or other catastrophe).
In general, C++ makes no such guarantee. If I do
Foo *foo = new Foo;
and never mention foo in a delete statement, the Foo destructor won't be
called.
> From the Python reference manual: "It is not guaranteed that __del__()
> methods are called for objects that still exist when the interpreter
> exits."
The same is true for destructors in C++.
> So I think what he's saying is that he wants a guarantee that
> __del__() gets called at some point, and I agree with him.
I think he means something different. If there was just a guarantee that
the destructor is called at some point, I believe he would not be
satisfied. Unfortunately, I still can't infer from that what it would
mean to integrate destructors into Python.
Regards,
Martin
More information about the Python-list
mailing list