summaryrefslogtreecommitdiff
path: root/Objects/methodobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-09-09 14:07:44 -0700
committerVictor Stinner <victor.stinner@gmail.com>2016-09-09 14:07:44 -0700
commit2615f24fb54cece9f22c5e2b1d206e8dd559631a (patch)
treee9f2abaed1d52f08c0d2fd75c303f76cd87eae3b /Objects/methodobject.c
parentf00ef48decd40fdba083bd2231430e1d71908d0b (diff)
downloadcpython-2615f24fb54cece9f22c5e2b1d206e8dd559631a.tar.gz
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.
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r--Objects/methodobject.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 394f1f4502..0fe3315417 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -155,6 +155,7 @@ _PyCFunction_FastCallDict(PyObject *func_obj, PyObject **args, Py_ssize_t nargs,
PyObject *result;
int flags;
+ assert(PyCFunction_Check(func));
assert(func != NULL);
assert(nargs >= 0);
assert(nargs == 0 || args != NULL);
@@ -243,6 +244,31 @@ _PyCFunction_FastCallDict(PyObject *func_obj, PyObject **args, Py_ssize_t nargs,
return result;
}
+PyObject *
+_PyCFunction_FastCallKeywords(PyObject *func, PyObject **stack,
+ Py_ssize_t nargs, PyObject *kwnames)
+{
+ PyObject *kwdict, *result;
+ Py_ssize_t nkwargs;
+
+ assert(PyCFunction_Check(func));
+
+ nkwargs = (kwnames == NULL) ? 0 : PyTuple_GET_SIZE(kwnames);
+ if (nkwargs > 0) {
+ kwdict = _PyStack_AsDict(stack + nargs, nkwargs, kwnames, func);
+ if (kwdict == NULL) {
+ return NULL;
+ }
+ }
+ else {
+ kwdict = NULL;
+ }
+
+ result = _PyCFunction_FastCallDict(func, stack, nargs, kwdict);
+ Py_XDECREF(kwdict);
+ return result;
+}
+
/* Methods (the standard built-in methods, that is) */
static void