[Python-checkins] cpython: Inline call_function()

victor.stinner python-checkins at python.org
Tue Jan 10 19:28:03 EST 2017


https://hg.python.org/cpython/rev/8481c379e2da
changeset:   106082:8481c379e2da
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Jan 11 00:54:57 2017 +0100
summary:
  Inline call_function()

Issue #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)

files:
  Python/ceval.c |  6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)


diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -36,7 +36,7 @@
 typedef PyObject *(*callproc)(PyObject *, PyObject *, PyObject *);
 
 /* Forward declarations */
-static PyObject * call_function(PyObject ***, Py_ssize_t, PyObject *);
+Py_LOCAL_INLINE(PyObject *) call_function(PyObject ***, Py_ssize_t, PyObject *);
 static PyObject * fast_function(PyObject *, PyObject **, Py_ssize_t, PyObject *);
 static PyObject * do_call_core(PyObject *, PyObject *, PyObject *);
 
@@ -4829,7 +4829,9 @@
     x = call; \
     }
 
-static PyObject* _Py_HOT_FUNCTION
+/* Issue #29227: Inline call_function() into _PyEval_EvalFrameDefault()
+   to reduce the stack consumption. */
+Py_LOCAL_INLINE(PyObject *) _Py_HOT_FUNCTION
 call_function(PyObject ***pp_stack, Py_ssize_t oparg, PyObject *kwnames)
 {
     PyObject **pfunc = (*pp_stack) - oparg - 1;

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list