fandino at usa.net
Tue Jun 8 11:43:26 CEST 1999
Graham Matthews wrote:
> I really don't understand this. A lot of languages (eg. Java) have
> garbage collection and finalisers. All these languages manage to delete
> objects in an order that does not cause any problems (all finalisers etc
I have been using Java since it was invented and I haven't programed a
finaliser ever. They should run under so unknown and inconsistent
environment that they are not usable at all (except for freeing external
> If a collector can do that in these languages why can't it do in
> Python (__del__ methods are Python's finalisers)?
Python __del__ methods are always called under consistent environments
so they can do really interesting thinks. I know a lot of cases where
you need complex __del__ methods: file buffers, persistent objects, etc.
> I am very very confused by your question. You seem to have a misconception
> about __del__ methods. They are finalisers, used only to close resources
> like files, etc. In a garbage collection scheme the __del__ methods are
> not used to implement the actual collection.
You are describing the usual java finaliser. Under Python or C++,
finalisers can do (and they usually do) better thinks than just freeing
BTW, how could be acceptable that the same __del__ method could be
called from two totally different schemes (GC reclaiming objects or
reference count becoming 0)? it would break all the library classes that
now use __del__ .
More information about the Python-list