From 79d6e8de9e07f31da726c28819e3506d38b22f1e Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 19 Apr 2016 23:37:17 +0300 Subject: Issue #26802: Optimized calling a function with *args only positional arguments. Patch by Joe Jevnik. --- Python/ceval.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Python/ceval.c b/Python/ceval.c index d69b8d6..88dc113 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; -- cgit v0.12