[Python-checkins] cpython: call_trampoline() now uses fast call

victor.stinner python-checkins at python.org
Fri Aug 19 19:50:39 EDT 2016


https://hg.python.org/cpython/rev/154f78d387f9
changeset:   102785:154f78d387f9
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Sat Aug 20 01:22:57 2016 +0200
summary:
  call_trampoline() now uses fast call

Issue #27128.

files:
  Python/sysmodule.c |  29 ++++++++++-------------------
  1 files changed, 10 insertions(+), 19 deletions(-)


diff --git a/Python/sysmodule.c b/Python/sysmodule.c
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -368,34 +368,25 @@
 call_trampoline(PyObject* callback,
                 PyFrameObject *frame, int what, PyObject *arg)
 {
-    PyObject *args;
-    PyObject *whatstr;
     PyObject *result;
+    PyObject *stack[3];
 
-    args = PyTuple_New(3);
-    if (args == NULL)
+    if (PyFrame_FastToLocalsWithError(frame) < 0) {
         return NULL;
-    if (PyFrame_FastToLocalsWithError(frame) < 0)
-        return NULL;
+    }
 
-    Py_INCREF(frame);
-    whatstr = whatstrings[what];
-    Py_INCREF(whatstr);
-    if (arg == NULL)
-        arg = Py_None;
-    Py_INCREF(arg);
-    PyTuple_SET_ITEM(args, 0, (PyObject *)frame);
-    PyTuple_SET_ITEM(args, 1, whatstr);
-    PyTuple_SET_ITEM(args, 2, arg);
+    stack[0] = (PyObject *)frame;
+    stack[1] = whatstrings[what];
+    stack[2] = (arg != NULL) ? arg : Py_None;
 
     /* call the Python-level function */
-    result = PyEval_CallObject(callback, args);
+    result = _PyObject_FastCall(callback, stack, 3, NULL);
+
     PyFrame_LocalsToFast(frame, 1);
-    if (result == NULL)
+    if (result == NULL) {
         PyTraceBack_Here(frame);
+    }
 
-    /* cleanup */
-    Py_DECREF(args);
     return result;
 }
 

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


More information about the Python-checkins mailing list