Simplify partial.__new__. (#813)

Fast paths in partial.__new__ no longer needed since concatenating with empty
tuple was optimized.
This commit is contained in:
Serhiy Storchaka 2017-03-25 12:10:16 +02:00 committed by Victor Stinner
parent 9f0aa4843f
commit 3c749fc867
1 changed files with 2 additions and 8 deletions

View File

@ -66,24 +66,18 @@ partial_new(PyTypeObject *type, PyObject *args, PyObject *kw)
Py_DECREF(pto); Py_DECREF(pto);
return NULL; return NULL;
} }
if (pargs == NULL || PyTuple_GET_SIZE(pargs) == 0) { if (pargs == NULL) {
pto->args = nargs; pto->args = nargs;
Py_INCREF(nargs);
}
else if (PyTuple_GET_SIZE(nargs) == 0) {
pto->args = pargs;
Py_INCREF(pargs);
} }
else { else {
pto->args = PySequence_Concat(pargs, nargs); pto->args = PySequence_Concat(pargs, nargs);
Py_DECREF(nargs);
if (pto->args == NULL) { if (pto->args == NULL) {
Py_DECREF(nargs);
Py_DECREF(pto); Py_DECREF(pto);
return NULL; return NULL;
} }
assert(PyTuple_Check(pto->args)); assert(PyTuple_Check(pto->args));
} }
Py_DECREF(nargs);
if (pkw == NULL || PyDict_GET_SIZE(pkw) == 0) { if (pkw == NULL || PyDict_GET_SIZE(pkw) == 0) {
if (kw == NULL) { if (kw == NULL) {