From: Serhiy Storchaka Date: Sat, 25 Mar 2017 10:10:16 +0000 (+0200) Subject: Simplify partial.__new__. (#813) X-Git-Tag: v3.7.0a1~1076 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3c749fc867f69deac75f866d5c1ba0f60e54c1fa;p=python Simplify partial.__new__. (#813) Fast paths in partial.__new__ no longer needed since concatenating with empty tuple was optimized. --- diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c index 592edbb614..567300e3f3 100644 --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -66,24 +66,18 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw) Py_DECREF(pto); return NULL; } - if (pargs == NULL || PyTuple_GET_SIZE(pargs) == 0) { + if (pargs == NULL) { pto->args = nargs; - Py_INCREF(nargs); - } - else if (PyTuple_GET_SIZE(nargs) == 0) { - pto->args = pargs; - Py_INCREF(pargs); } else { pto->args = PySequence_Concat(pargs, nargs); + Py_DECREF(nargs); if (pto->args == NULL) { - Py_DECREF(nargs); Py_DECREF(pto); return NULL; } assert(PyTuple_Check(pto->args)); } - Py_DECREF(nargs); if (pkw == NULL || PyDict_GET_SIZE(pkw) == 0) { if (kw == NULL) {