[Python-Dev] tp_finalize vs tp_del sematics (original) (raw)

Maciej Fijalkowski fijall at gmail.com
Thu Sep 3 21:08:07 CEST 2015


On Thu, Sep 3, 2015 at 9:23 AM, Valentine Sinitsyn <valentine.sinitsyn at gmail.com> wrote:

Hi Armin,

On 25.08.2015 13:00, Armin Rigo wrote:

Hi Valentine, On 25 August 2015 at 09:56, Valentine Sinitsyn <valentine.sinitsyn at gmail.com> wrote:

Yes, I think so. There is a highly obscure corner case: del will still be called several times if you declare your class with "slots=()".

Even on "post-PEP-0442" Python 3.4+? Could you share a link please? class X(object): slots=() # <= try with and without this def del(self): global revive revive = self print("hi") X() revive = None revive = None revive = None By accident, I found a solution to this puzzle: class X(object): slots = () class Y(object): pass import gc gc.istracked(X()) # False gc.istracked(Y()) # True An object with empty slots is naturally untracked, as it can't create back references. Valentine


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/fijall%40gmail.com

That does not make it ok to have del called several time, does it?



More information about the Python-Dev mailing list