From a50750d18931d26248ce52951838a605dca9651a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 23 Aug 2016 00:23:23 +0200 Subject: Issue #27809: methodcaller_reduce() uses fast call --- Modules/_operator.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'Modules/_operator.c') diff --git a/Modules/_operator.c b/Modules/_operator.c index dfff1d2faa..fb8eafc679 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); } -- cgit v1.2.1