mirror of
https://github.com/python/cpython.git
synced 2025-11-03 03:22:27 +00:00
call_function_tail() uses fast call
Issue #27128: Modify call_function_tail() to use _PyObject_FastCall() when args is not a tuple to avoid the creation of a temporary tuple. call_function_tail() is used by: * PyObject_CallFunction() * PyObject_CallMethod() * _PyObject_CallMethodId()
This commit is contained in:
parent
3f745bf1d9
commit
8880708f81
1 changed files with 6 additions and 13 deletions
|
|
@ -2272,27 +2272,20 @@ exit:
|
||||||
static PyObject*
|
static PyObject*
|
||||||
call_function_tail(PyObject *callable, PyObject *args)
|
call_function_tail(PyObject *callable, PyObject *args)
|
||||||
{
|
{
|
||||||
PyObject *retval;
|
PyObject *result;
|
||||||
|
|
||||||
if (args == NULL)
|
if (args == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!PyTuple_Check(args)) {
|
if (!PyTuple_Check(args)) {
|
||||||
PyObject *a;
|
result = _PyObject_FastCall(callable, &args, 1, NULL);
|
||||||
|
}
|
||||||
a = PyTuple_New(1);
|
else {
|
||||||
if (a == NULL) {
|
result = PyObject_Call(callable, args, NULL);
|
||||||
Py_DECREF(args);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
PyTuple_SET_ITEM(a, 0, args);
|
|
||||||
args = a;
|
|
||||||
}
|
}
|
||||||
retval = PyObject_Call(callable, args, NULL);
|
|
||||||
|
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
|
return result;
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *
|
PyObject *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue