Skip to content

Commit

Permalink
Simplify partial.__new__. (python#813)
Browse files Browse the repository at this point in the history
Fast paths in partial.__new__ no longer needed since concatenating with empty
tuple was optimized.
  • Loading branch information
serhiy-storchaka authored and vstinner committed Mar 25, 2017
1 parent 9f0aa48 commit 3c749fc
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions Modules/_functoolsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 3c749fc

Please sign in to comment.