19 Jun
2019
19 Jun
'19
8:39 a.m.
On 2019-06-19 00:59, Victor Stinner wrote:
Example:
PyObject* args[] = {arg1, arg2}; res = _PyObject_FastCall(func, args, Py_ARRAY_LENGTH(args));
They are many ways to write the same code:
PyObject* args[2] = {arg1, arg2}; res = _PyObject_FastCall(func, args, 2);
Right, but it's slightly inconvenient because you need to define the array separately. The most common way in the CPython sources to call a function with known positional arguments is PyObject_FunctionObjArgs(), which is less efficient. Part of the reason why PyObject_FunctionObjArgs() is used is simply because it's easier to use than _PyObject_FastCall().