[Cython] PEP 442: safe object finalisation

Stefan Behnel stefan_ml at behnel.de
Mon Aug 5 10:40:56 CEST 2013


Torsten Landschoff, 05.08.2013 10:02:
> On 08/03/2013 06:24 PM, Stefan Behnel wrote:
>> 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.
> I read the PEP and was wondering about the performance of this part:
> 
>  1. *The CI is traversed again to determine if it is still isolated. If
>     it is determined that at least one object in CI is now reachable
>     from outside the CI, this collection is aborted and the whole CI is
>     resurrected. Otherwise, proceed.*
> 
> AFAICT it will not suffice to traverse the CI here. Instead, all active
> objects must be traversed which seems to be quite expensive.

My attempts to implement support for this suggested that this feature is
not entirely thought out yet. I think it needs some more discussion on the
python-dev list (despite the fact that the PEP has been accepted already).


> Does this mean that you will not pull my gc_no_clear changes from
> https://github.com/cython/cython/pull/248 in favor of this better fix?
> Or should I update it so that gc_no_clear only has an affect on Python <
> 3.4?

I see the two features as completely unrelated. All that should really
change with PEP 442 is the time at which the finalisation runs during
cyclic garbage collection, iff the type supports GC.

Stefan



More information about the cython-devel mailing list