From: Serhiy Storchaka Date: Tue, 19 Apr 2016 20:37:17 +0000 (+0300) Subject: Issue #26802: Optimized calling a function with *args only positional arguments. X-Git-Tag: v3.6.0a1~163 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=79d6e8de9e07f31da726c28819e3506d38b22f1e;p=thirdparty%2FPython%2Fcpython.git Issue #26802: Optimized calling a function with *args only positional arguments. Patch by Joe Jevnik. --- diff --git a/Python/ceval.c b/Python/ceval.c index d69b8d6cc6d9..88dc1139eb09 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -4890,6 +4890,21 @@ update_star_args(int nstack, int nstar, PyObject *stararg, { PyObject *callargs, *w; + if (!nstack) { + if (!stararg) { + /* There are no positional arguments on the stack and there is no + sequence to be unpacked. */ + return PyTuple_New(0); + } + if (PyTuple_CheckExact(stararg)) { + /* No arguments are passed on the stack and the sequence is not a + tuple subclass so we can just pass the stararg tuple directly + to the function. */ + Py_INCREF(stararg); + return stararg; + } + } + callargs = PyTuple_New(nstack + nstar); if (callargs == NULL) { return NULL;