[Python-Dev] PEP 442 accepted

Antoine Pitrou solipsis at pitrou.net
Fri Jun 14 19:34:41 CEST 2013


On Wed, 5 Jun 2013 09:10:54 -0700
Benjamin Peterson <benjamin at python.org> wrote:
> I (and Guido) are accepting PEP 442 (Safe object finalization) on the
> condition that finalizers are only ever called once globally.

Ok, so there's an issue with that condition: it can't be upholded on
non-GC objects. Creating a non-GC object is quite obscure and rare,
though, since it requires basically a class with no __dict__ and an
empty __slots__:

class C:
    __slots__ = ()
    survivors = []

    def __del__(self):
        self.survivors.append(self)


In this case, a C instance's __del__ will be called every time
destruction is attempted, not only once. Is that a realistic problem?

Regards

Antoine.


More information about the Python-Dev mailing list