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

victor.stinner python-checkins at python.org
Fri Aug 19 11:32:17 EDT 2016


https://hg.python.org/cpython/rev/7cd479573de9
changeset:   102758:7cd479573de9
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Aug 19 16:44:19 2016 +0200
summary:
  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()

files:
  Objects/abstract.c |  19 ++++++-------------
  1 files changed, 6 insertions(+), 13 deletions(-)


diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2272,27 +2272,20 @@
 static PyObject*
 call_function_tail(PyObject *callable, PyObject *args)
 {
-    PyObject *retval;
+    PyObject *result;
 
     if (args == NULL)
         return NULL;
 
     if (!PyTuple_Check(args)) {
-        PyObject *a;
-
-        a = PyTuple_New(1);
-        if (a == NULL) {
-            Py_DECREF(args);
-            return NULL;
-        }
-        PyTuple_SET_ITEM(a, 0, args);
-        args = a;
+        result = _PyObject_FastCall(callable, &args, 1, NULL);
     }
-    retval = PyObject_Call(callable, args, NULL);
+    else {
+        result = PyObject_Call(callable, args, NULL);
+    }
 
     Py_DECREF(args);
-
-    return retval;
+    return result;
 }
 
 PyObject *

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


More information about the Python-checkins mailing list