-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Giving a direct access to an array of PyObject* (PyObject**) is causing issues with other Python implementations, like PyPy, which don't use PyObject internally.
https://bugs.python.org/issue41078 converts PyTuple_GET_ITEM() macro to a static inline function which prevents to write &PyTuple_GET_ITEM().
Cython uses it at exactly 4 lines (in 3 functions).
__Pyx_CyFunction_CallAsMethod() uses::
#if CYTHON_METH_FASTCALL
// Prefer vectorcall if available. This is not the typical case, as
// CPython would normally use vectorcall directly instead of tp_call.
__pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
if (vc) {
return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), PyTuple_GET_SIZE(args), kw);
}
#endif
__Pyx_PyFunction_FastCallDict() and __Pyx__GetModuleGlobalName() use::
/* function called with no arguments, but all parameters have
a default value: use default values as arguments .*/
args = &PyTuple_GET_ITEM(argdefs, 0);
result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
(...)
k = &PyTuple_GET_ITEM(kwtuple, 0);
(...)
d = &PyTuple_GET_ITEM(argdefs, 0);
One option is to use _PyTuple_ITEMS() providing by the internal pycore_tuple.h header file... but I strongly discourage to use the internal C API. It would make C extensions tightly coupled with CPython versions, break at every single Python release (the internal C API does not provide any kind of backward compatibiltiy warranty), etc.