diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c --- a/Modules/_functoolsmodule.c +++ b/Modules/_functoolsmodule.c @@ -709,6 +709,14 @@ /* short path, key will match args anyway, which is a tuple */ if (!typed && !kwds) { + if (PyTuple_GET_SIZE(args) == 1) { + /* Save space and improve speed by unwrapping 1-tuples */ + key = PyTuple_GET_ITEM(args, 0); + if (!PyTuple_CheckExact(key)) { + Py_INCREF(key); + return key; + } + } Py_INCREF(args); return args; }