diff options
-rw-r--r-- | Objects/funcobject.c | 53 |
1 files changed, 6 insertions, 47 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c index 63aa9de..a3af4b3 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -563,55 +563,14 @@ func_traverse(PyFunctionObject *f, visitproc visit, void *arg) } static PyObject * -function_call(PyObject *func, PyObject *arg, PyObject *kw) +function_call(PyObject *func, PyObject *args, PyObject *kwargs) { - PyObject *result; - PyObject *argdefs; - PyObject *kwtuple = NULL; - PyObject **d, **k; - Py_ssize_t nk, nd; - - argdefs = PyFunction_GET_DEFAULTS(func); - if (argdefs != NULL && PyTuple_Check(argdefs)) { - d = &PyTuple_GET_ITEM((PyTupleObject *)argdefs, 0); - nd = PyTuple_GET_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } - - if (kw != NULL && PyDict_Check(kw)) { - Py_ssize_t pos, i; - nk = PyDict_GET_SIZE(kw); - kwtuple = PyTuple_New(2*nk); - if (kwtuple == NULL) - return NULL; - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kw, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i/2; - } - else { - k = NULL; - nk = 0; - } - - result = PyEval_EvalCodeEx( - PyFunction_GET_CODE(func), - PyFunction_GET_GLOBALS(func), (PyObject *)NULL, - &PyTuple_GET_ITEM(arg, 0), PyTuple_GET_SIZE(arg), - k, nk, d, nd, - PyFunction_GET_KW_DEFAULTS(func), - PyFunction_GET_CLOSURE(func)); - - Py_XDECREF(kwtuple); + PyObject **stack; + Py_ssize_t nargs; - return result; + stack = &PyTuple_GET_ITEM(args, 0); + nargs = PyTuple_GET_SIZE(args); + return _PyFunction_FastCallDict(func, stack, nargs, kwargs); } /* Bind a function to an object */ |