changeset: 101068:15b20201cfa5 user: Serhiy Storchaka date: Tue Apr 19 23:37:17 2016 +0300 files: Python/ceval.c description: Issue #26802: Optimized calling a function with *args only positional arguments. Patch by Joe Jevnik. diff -r 75f40345d784 -r 15b20201cfa5 Python/ceval.c --- a/Python/ceval.c Tue Apr 19 22:29:11 2016 +0200 +++ b/Python/ceval.c Tue Apr 19 23:37:17 2016 +0300 @@ -4890,6 +4890,21 @@ { 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;