Use PyObject_CallFunctionObjArgs()

Issue #28915: Replace PyObject_CallFunction() with
PyObject_CallFunctionObjArgs() when the format string was only made of "O"
formats, PyObject* arguments.

PyObject_CallFunctionObjArgs() avoids the creation of a temporary tuple and
doesn't have to parse a format string.
This commit is contained in:
Victor Stinner 2016-12-09 16:22:32 +01:00
parent 55ba38a480
commit 5abaa2b139
3 changed files with 16 additions and 10 deletions

View file

@ -2549,7 +2549,7 @@ _PyObject_CallFunctionVa(PyObject *callable, const char *format,
}
if (nargs == 1 && PyTuple_Check(stack[0])) {
/* Special cases:
/* Special cases for backward compatibility:
- PyObject_CallFunction(func, "O", tuple) calls func(*tuple)
- PyObject_CallFunction(func, "(OOO)", arg1, arg2, arg3) calls
func(*(arg1, arg2, arg3)): func(arg1, arg2, arg3) */

View file

@ -1454,7 +1454,7 @@ property_copy(PyObject *old, PyObject *get, PyObject *set, PyObject *del)
doc = pold->prop_doc ? pold->prop_doc : Py_None;
}
new = PyObject_CallFunction(type, "OOOO", get, set, del, doc);
new = PyObject_CallFunctionObjArgs(type, get, set, del, doc, NULL);
Py_DECREF(type);
if (new == NULL)
return NULL;