Issue #27810: Add _PyCFunction_FastCallKeywords()
Use _PyCFunction_FastCallKeywords() in ceval.c: it allows to remove a lot of
code from ceval.c which was only used to call C functions.
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 508fd82..9de6b83 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2366,7 +2366,7 @@
return result;
}
-static PyObject *
+PyObject *
_PyStack_AsDict(PyObject **values, Py_ssize_t nkwargs, PyObject *kwnames,
PyObject *func)
{
@@ -2415,10 +2415,13 @@
assert((nargs == 0 && nkwargs == 0) || stack != NULL);
if (PyFunction_Check(func)) {
- /* Fast-path: avoid temporary tuple or dict */
return _PyFunction_FastCallKeywords(func, stack, nargs, kwnames);
}
+ if (PyCFunction_Check(func)) {
+ return _PyCFunction_FastCallKeywords(func, stack, nargs, kwnames);
+ }
+
if (nkwargs > 0) {
kwdict = _PyStack_AsDict(stack + nargs, nkwargs, kwnames, func);
if (kwdict == NULL) {