diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-04-19 20:37:17 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-04-19 20:37:17 (GMT) |
commit | 79d6e8de9e07f31da726c28819e3506d38b22f1e (patch) | |
tree | 5db66f958462589a7d2ae9baec74b8badb6f91e9 /Python | |
parent | 5bfe0da80840bf6a0edcf7be2482ac584125ede1 (diff) | |
download | cpython-79d6e8de9e07f31da726c28819e3506d38b22f1e.zip cpython-79d6e8de9e07f31da726c28819e3506d38b22f1e.tar.gz cpython-79d6e8de9e07f31da726c28819e3506d38b22f1e.tar.bz2 |
Issue #26802: Optimized calling a function with *args only positional arguments.
Patch by Joe Jevnik.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 15 |
1 files changed, 15 insertions, 0 deletions
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; |