Skip to content

Commit 415c510

Browse files
committed
Inline call_function()
Issue python#29227: Inline call_function() into _PyEval_EvalFrameDefault() using Py_LOCAL_INLINE to reduce the stack consumption. It reduces the stack consumption, bytes per call, before => after: test_python_call: 1152 => 1040 (-112 B) test_python_getitem: 1008 => 976 (-32 B) test_python_iterator: 1232 => 1120 (-112 B) => total: 3392 => 3136 (- 256 B)
1 parent 434723f commit 415c510

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Python/ceval.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extern int _PyObject_GetMethod(PyObject *, PyObject *, PyObject **);
3636
typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *);
3737

3838
/* Forward declarations */
39-
static PyObject * call_function(PyObject ***, Py_ssize_t, PyObject *);
39+
Py_LOCAL_INLINE(PyObject *) call_function(PyObject ***, Py_ssize_t, PyObject *);
4040
static PyObject * fast_function(PyObject *, PyObject **, Py_ssize_t, PyObject *);
4141
static PyObject * do_call_core(PyObject *, PyObject *, PyObject *);
4242

@@ -4829,7 +4829,9 @@ if (tstate->use_tracing && tstate->c_profilefunc) { \
48294829
x = call; \
48304830
}
48314831

4832-
static PyObject* _Py_HOT_FUNCTION
4832+
/* Issue #29227: Inline call_function() into _PyEval_EvalFrameDefault()
4833+
to reduce the stack consumption. */
4834+
Py_LOCAL_INLINE(PyObject *) _Py_HOT_FUNCTION
48334835
call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
48344836
{
48354837
PyObject **pfunc = (*pp_stack) - oparg - 1;

0 commit comments

Comments
 (0)