[Python-checkins] cpython: Issue #27809: methodcaller_reduce() uses fast call

victor.stinner python-checkins at python.org
Mon Aug 22 18:32:47 EDT 2016


https://hg.python.org/cpython/rev/60660890459f
changeset:   102851:60660890459f
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Tue Aug 23 00:23:23 2016 +0200
summary:
  Issue #27809: methodcaller_reduce() uses fast call

files:
  Modules/_operator.c |  18 +++++++-----------
  1 files changed, 7 insertions(+), 11 deletions(-)


diff --git a/Modules/_operator.c b/Modules/_operator.c
--- a/Modules/_operator.c
+++ b/Modules/_operator.c
@@ -1111,6 +1111,8 @@
         PyObject *functools;
         PyObject *partial;
         PyObject *constructor;
+        PyObject *newargs[2];
+
         _Py_IDENTIFIER(partial);
         functools = PyImport_ImportModule("functools");
         if (!functools)
@@ -1119,17 +1121,11 @@
         Py_DECREF(functools);
         if (!partial)
             return NULL;
-        newargs = PyTuple_New(2);
-        if (newargs == NULL) {
-            Py_DECREF(partial);
-            return NULL;
-        }
-        Py_INCREF(Py_TYPE(mc));
-        PyTuple_SET_ITEM(newargs, 0, (PyObject *)Py_TYPE(mc));
-        Py_INCREF(mc->name);
-        PyTuple_SET_ITEM(newargs, 1, mc->name);
-        constructor = PyObject_Call(partial, newargs, mc->kwds);
-        Py_DECREF(newargs);
+
+        newargs[0] = (PyObject *)Py_TYPE(mc);
+        newargs[1] = mc->name;
+        constructor = _PyObject_FastCallDict(partial, newargs, 2, mc->kwds);
+
         Py_DECREF(partial);
         return Py_BuildValue("NO", constructor, mc->args);
     }

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


More information about the Python-checkins mailing list