Skip to content

Commit 155ea65

Browse files
committed
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.
1 parent 2990fa1 commit 155ea65

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

‎Python/ceval.c‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4590,30 +4590,22 @@ PyEval_CallObjectWithKeywords(PyObject *func, PyObject *args, PyObject *kwargs)
45904590
#endif
45914591

45924592
if (args == NULL) {
4593-
if (kwargs == NULL) {
4594-
return _PyObject_CallNoArg(func);
4595-
}
4596-
4597-
args = PyTuple_New(0);
4598-
if (args == NULL)
4599-
return NULL;
4593+
return _PyObject_FastCallDict(func, NULL, 0, kwargs);
46004594
}
4601-
else if (!PyTuple_Check(args)) {
4595+
4596+
if (!PyTuple_Check(args)) {
46024597
PyErr_SetString(PyExc_TypeError,
46034598
"argument list must be a tuple");
46044599
return NULL;
46054600
}
4606-
else {
4607-
Py_INCREF(args);
4608-
}
46094601

46104602
if (kwargs != NULL && !PyDict_Check(kwargs)) {
46114603
PyErr_SetString(PyExc_TypeError,
46124604
"keyword list must be a dictionary");
4613-
Py_DECREF(args);
46144605
return NULL;
46154606
}
46164607

4608+
Py_INCREF(args);
46174609
result = PyObject_Call(func, args, kwargs);
46184610
Py_DECREF(args);
46194611

0 commit comments

Comments
 (0)