[Cython] cdef class tp_new should call PyBaseObject_Type.tp_new?

Simon Jagoe simon at simonjagoe.com
Thu Jan 9 14:04:20 CET 2014

Hi Stefan,

> 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?

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.

Aside from your comment that it would need extensive testing, am I
missing some other problems?


More information about the cython-devel mailing list