[Cython] [cython-users] Re: Cython classes and attribute cache

Stefan Behnel stefan_ml at behnel.de
Sat Apr 6 22:33:22 CEST 2013


Stefan Behnel, 06.04.2013 21:58:
> Nils Bruin, 06.04.2013 21:37:
>> I can confirm that changing Compiler/TypeSlots.py, line 380 from:
>>
>> value = "Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|
>> Py_TPFLAGS_HAVE_NEWBUFFER"
>>
>> to:
>>
>> value = "Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|
>> Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_VERSION_TAG"
>>
>> indeed makes the difference in timing disappear. For extension classes
>> that don't mess directly with their tp_dict having this flag should be
>> entirely safe.
>>
>> See http://bugs.python.org/issue1700288 for background on the
>> introduction of the method cache in python and http://bugs.python.org/issue1878
>> for the reason why the flag is not included in Py_TPFLAGS_DEFAULT on
>> 2.7, but is in 3.*.
> 
> I wouldn't mind making it an "on by default" compiler directive. That would
> mean that you could switch it off with a class decorator at need.

Proposed patch:

https://github.com/scoder/cython/commit/b1f10fa2c1bbb0a076807a9f391204c6a997ba9a


> Any objections?

Stefan



More information about the cython-devel mailing list