does python have useless destructors?

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Jun 15 06:56:18 EDT 2004


On Tue, 15 Jun 2004 10:41:27 +0000, Manlio Perillo wrote:

> Since __del__ isn't really 'useful', *maybe* a better solution is to
> add another special method for classes, ad example a __finalize__
> method.
> Such method, if present, *will* be called during stack unwinding.

Called for all objects referred to by local variables, even those which
are also referred to by other variables? It does not make sense. For
example if you pass a file to a function, and the function temporarily
stores the file in its local variable, it would close it.

Called for objects which don't have other references? It's unimplementable
efficiently, and in a way which breaks easy integration with the garbage
collected host language.

-- 
   __("<         Marcin Kowalczyk
   \__/       qrczak at knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/




More information about the Python-list mailing list