[Python-3000] Removing __del__
Jim Jewett
jimjjewett at gmail.com
Tue Sep 26 16:12:15 CEST 2006
On 9/26/06, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
> "Giovanni Bajo" <rasky at develer.com> writes:
> > Guido was proposing a solution with __del__ and CT, which
> > approximately worked this way:
> > - When a CT is detected, any __del__ method is invoked once per
> > instance, in random order.
[Note that this "__del__" is closer to what we've been calling
__close__ than to the existing __del__.]
Note that the "at most" part of "once" is already a stronger promise
than __close__. That's OK (maybe even helpful) for users, it just
makes the implementation harder.
> This means that __del__ [~= __close__] may attempt to use an object which
> has already had its __del__ called.
Yes; this is the most important change between between today's __del__
and the proposed __close__.
Today's __del__ doesn't have to defend against messed up subobjects,
because it immortalizes them. A __close__ method would need to defend
against this, because of the arbitrary ordering.
In practice, close methods already defend against this anyhow, largely
because they know that they might be called by __del__ even after
being called explicitly.
-jJ
More information about the Python-3000
mailing list