Skip to content

Commit

Permalink
PyEval_CallObjectWithKeywords() uses fast call with kwargs
Browse files Browse the repository at this point in the history
Issue #27809. _PyObject_FastCallDict() now supports keyword arguments, and so
the args==NULL fast-path can also be used when kwargs is not NULL.
  • Loading branch information
vstinner committed Aug 22, 2016
1 parent 2990fa1 commit 155ea65
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4590,30 +4590,22 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
#endif

if (args == NULL) {
if (kwargs == NULL) {
return _PyObject_CallNoArg(func);
}

args = PyTuple_New(0);
if (args == NULL)
return NULL;
return _PyObject_FastCallDict(func, NULL, 0, kwargs);
}
else if (!PyTuple_Check(args)) {

if (!PyTuple_Check(args)) {
PyErr_SetString(PyExc_TypeError,
"argument list must be a tuple");
return NULL;
}
else {
Py_INCREF(args);
}

if (kwargs != NULL && !PyDict_Check(kwargs)) {
PyErr_SetString(PyExc_TypeError,
"keyword list must be a dictionary");
Py_DECREF(args);
return NULL;
}

Py_INCREF(args);
result = PyObject_Call(func, args, kwargs);
Py_DECREF(args);

Expand Down

0 comments on commit 155ea65

Please sign in to comment.