mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
call_method() now uses _PyObject_FastCall()
Issue #29233: Replace the inefficient _PyObject_VaCallFunctionObjArgs() with _PyObject_FastCall() in call_method() and call_maybe(). Only a few functions call call_method() and call it with a fixed number of arguments. Avoid the complex and expensive _PyObject_VaCallFunctionObjArgs() function, replace it with an array allocated on the stack with the exact number of argumlents. It reduces the stack consumption, bytes per call, before => after: test_python_call: 1168 => 1152 (-16 B) test_python_getitem: 1344 => 1008 (-336 B) test_python_iterator: 1568 => 1232 (-336 B) Remove the _PyObject_VaCallFunctionObjArgs() function which became useless. Rename it to object_vacall() and make it private.
This commit is contained in:
parent
dbdfecebd2
commit
434723f94c
3 changed files with 66 additions and 52 deletions
|
|
@ -2700,8 +2700,8 @@ _PyObject_CallMethodId_SizeT(PyObject *obj, _Py_Identifier *name,
|
|||
return retval;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
_PyObject_VaCallFunctionObjArgs(PyObject *callable, va_list vargs)
|
||||
static PyObject *
|
||||
object_vacall(PyObject *callable, va_list vargs)
|
||||
{
|
||||
PyObject *small_stack[_PY_FASTCALL_SMALL_STACK];
|
||||
PyObject **stack;
|
||||
|
|
@ -2767,7 +2767,7 @@ PyObject_CallMethodObjArgs(PyObject *callable, PyObject *name, ...)
|
|||
}
|
||||
|
||||
va_start(vargs, name);
|
||||
result = _PyObject_VaCallFunctionObjArgs(callable, vargs);
|
||||
result = object_vacall(callable, vargs);
|
||||
va_end(vargs);
|
||||
|
||||
Py_DECREF(callable);
|
||||
|
|
@ -2791,7 +2791,7 @@ _PyObject_CallMethodIdObjArgs(PyObject *obj,
|
|||
}
|
||||
|
||||
va_start(vargs, name);
|
||||
result = _PyObject_VaCallFunctionObjArgs(callable, vargs);
|
||||
result = object_vacall(callable, vargs);
|
||||
va_end(vargs);
|
||||
|
||||
Py_DECREF(callable);
|
||||
|
|
@ -2805,7 +2805,7 @@ PyObject_CallFunctionObjArgs(PyObject *callable, ...)
|
|||
PyObject *result;
|
||||
|
||||
va_start(vargs, callable);
|
||||
result = _PyObject_VaCallFunctionObjArgs(callable, vargs);
|
||||
result = object_vacall(callable, vargs);
|
||||
va_end(vargs);
|
||||
|
||||
return result;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue