Split the current "CYTHON_COMPILING_IN_LIMITED_API" macro guard#3611
Split the current "CYTHON_COMPILING_IN_LIMITED_API" macro guard#3611
Conversation
…ince that adds the module reference with PEP-573.
…pes since we do not want to keep the module alive just because other modules still refer to the type.
828223e to
addf112
Compare
…separate feature guards:
1) using a global module state struct ("CYTHON_USE_MODULE_STATE")
2) using PyType_FromSpec() for extension types ("CYTHON_USE_TYPE_FROM_SPEC")
3) actual limited-API special casing ("CYTHON_COMPILING_IN_LIMITED_API")
… we are not compiling against the Limited-API.
…top relying on the PyTypeObject struct being available in several places by using the type pointer instead (and setting it early enough). Rename "CYTHON_USE_TYPE_FROM_SPEC" feature flag to "CYTHON_USE_TYPE_SPECS".
… coroutines) was only added in 3.5, and 3.4 is out of maintenance anyway.
| #if CYTHON_USE_TYPE_SPECS && PY_VERSION_HEX >= 0x03080000 | ||
| // In Py3.8+, instances of heap types need to decref their type on deallocation. | ||
| // https://bugs.python.org/issue35810 | ||
| #define __Pyx_PyHeapTypeObject_GC_Del(obj) { \ |
There was a problem hiding this comment.
Does this mean that you should also include the heap types in tp_traverse and tp_clear? (https://bugs.python.org/issue42972)
There was a problem hiding this comment.
Erm, yes… I hadn't thought about that yet, but sure, it's a live reference that can participate in reference cycles, any time.
Good call.
There was a problem hiding this comment.
I think this is the relevant change: python/cpython@1cf15af
(note that it contains a removal of a previous change that tried a generic implementation).
…only if it's really included.
|
It seems that when using |
|
The only remaining issue with the "type specs" tests is that profiling apparently counts cpdef functions twice, for wrapper and underlying function. That suggests a bug in Cython. But I agree that we don't have to wait for that. The overall changes are valuable already. |
|
There's still #3611 (comment) to be resolved. Heap types need GC support. |
…t is disabled for them.
…fference with coroutine copying.
|
Merged. Finally. Let's see how many PRs this breaks. :) |
Use separate feature guards for: