[Python-3000] Removing __del__

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Mon Sep 25 13:02:14 CEST 2006

Greg Ewing <greg.ewing at canterbury.ac.nz> writes:

> All use of weakrefs can be hidden behind a call such as
>    register_finalizer(self, func, *args, **kwds)

It should be possible to finalize the object explicitly, given a
handle returned by this function, and possibly to kill the finalizer
without execution.

The former is useful to implement close(). The latter is useful for
weak dictionaries: when an entry is removed because it's overwritten,
there is no need to keep a finalizer which will remove the old entry
when the key dies.

IMHO a weak reference can conveniently play the role of such handle.

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

More information about the Python-3000 mailing list