summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-22 21:26:00 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-08-22 21:26:00 (GMT)
commit155ea65e5c88d250a752ee5321860ef11ede4085 (patch)
tree88d328b18d1c385c872c057e2fb42d75c463f8f4
parent2990fa11bc6f8a78b90a2a742756a6fd45c4833d (diff)
downloadcpython-155ea65e5c88d250a752ee5321860ef11ede4085.zip
cpython-155ea65e5c88d250a752ee5321860ef11ede4085.tar.gz
cpython-155ea65e5c88d250a752ee5321860ef11ede4085.tar.bz2
PyEval_CallObjectWithKeywords() uses fast call with kwargs
Issue #27809. _PyObject_FastCallDict() now supports keyword arguments, and so the args==NULL fast-path can also be used when kwargs is not NULL.
-rw-r--r--Python/ceval.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 9c65937..fd456ce 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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);