summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-08-22 22:23:23 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-08-22 22:23:23 (GMT)
commit7e7823a03785925573b732be30e97f8585272f18 (patch)
tree4582afdb92ef51b0270e7539eab9149bf284c009 /Modules
parent6412f4993ab497de7e15e2578da52fc2a9c14f1d (diff)
downloadcpython-7e7823a03785925573b732be30e97f8585272f18.zip
cpython-7e7823a03785925573b732be30e97f8585272f18.tar.gz
cpython-7e7823a03785925573b732be30e97f8585272f18.tar.bz2
Issue #27809: methodcaller_reduce() uses fast call
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_operator.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/Modules/_operator.c b/Modules/_operator.c
index dfff1d2..fb8eafc 100644
--- a/Modules/_operator.c
+++ b/Modules/_operator.c
@@ -1111,6 +1111,8 @@ methodcaller_reduce(methodcallerobject *mc)
PyObject *functools;
PyObject *partial;
PyObject *constructor;
+ PyObject *newargs[2];
+
_Py_IDENTIFIER(partial);
functools = PyImport_ImportModule("functools");
if (!functools)
@@ -1119,17 +1121,11 @@ methodcaller_reduce(methodcallerobject *mc)
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);
}