[Cython] PEP 442: safe object finalisation

Stefan Behnel stefan_ml at behnel.de
Thu Aug 8 05:50:29 CEST 2013


Stefan Behnel, 03.08.2013 18:24:
> CPython 3.4 will have a new way to handle object finalisation.
> 
> http://www.python.org/dev/peps/pep-0442/
> 
> I think we should switch the current deallocation code to make use of it.
> That should fix the problem we currently have with user provided
> __dealloc__() code that touches Python objects. It would be Py3.4+
> specific, though.

... and I found out that there is no guarantee that tp_finalize() gets
called. It's meant to map 1:1 to the __del__() Python method, so Python
subtypes have to explicitly call their supertype's __del__() method,
otherwise it won't be executed. I don't think that's suitable for the use
case in Cython, so we should stick with tp_dealloc().

Stefan



More information about the cython-devel mailing list