[Cython] cdef class tp_new should call PyBaseObject_Type.tp_new?
Stefan Behnel
stefan_ml at behnel.de
Fri Jan 10 10:11:44 CET 2014
Simon Jagoe, 09.01.2014 14:04:
>> Looking at the code in Py3, ISTM that it would be sufficient to do this iff
>>
>> (t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) != 0
>>
>> which should be rare enough.
>>
>> Obviously requires some user side testing to see if it breaks any other code...
>
> Thanks for looking at this. I am wondering if there is a reason why the
> tp_alloc can't be replaced with the PyBaseObject_Type->tp_new directly?
I don't know. At least, it's some unnecessary overhead in almost all cases.
Not sure if that matters, there's enough costly stuff happening at this
point anyway.
ISTM that we'd also have to fix the issue that Nils Bruin found, otherwise
we'd risk even more trouble on user side.
http://thread.gmane.org/gmane.comp.python.cython.user/10267
> My understanding is that initially, object's tp_new essentially just
> called tp_alloc as Cython does now. Later the abc feature was added
> with the abstract check happening in object's tp_new, while not changing
> previous (non-abstract class) behavior. If Cython were to use this
> instead of tp_alloc, it would be forward-compatible with future changes
> to object.
Agreed.
Stefan
More information about the cython-devel
mailing list