[Python-3000] Removing __del__

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Tue Sep 19 20:48:11 CEST 2006


"Jim Jewett" <jimjjewett at gmail.com> writes:

> I do think we should split __del__ into the (rare, problematic)
> general case and a "special-purpose" lightweight __close__ version
> that does a better job in the normal case.

A synchronous finalizer which doesn't keep object it refers to alive,
like Python's __del__, is sufficient when the finalizer doesn't use
other finalizable objects, and doesn't conflict with the rest of the
program in terms of potentially concurrent operations on shared data
(read/write or write/write).

Note that the concurrency conflict can manifest even in a
single-threaded program, because __del__ finalizers are in fact
semi-asynchronous: they are invoked when a reference count is
decremented and causes the relevant object to become dead, which
can happen in lots of places, even on a seemingly innocent variable
assignment.

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


More information about the Python-3000 mailing list