cpython: f9dd607dc04c (original) (raw)
Mercurial > cpython
changeset 105973:f9dd607dc04c
Optimize _PyFunction_FastCallDict() when kwargs is {} Issue #28839: Optimize _PyFunction_FastCallDict() when kwargs is an empty dictionary, avoid the creation of an useless empty tuple. [#28839]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Tue, 03 Jan 2017 02:01:42 +0100 |
parents | 5f7cd3b6c9b1 |
children | e651f8292011 |
files | Python/ceval.c |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-)[+] [-] Python/ceval.c 8 |
line wrap: on
line diff
--- a/Python/ceval.c +++ b/Python/ceval.c @@ -5040,9 +5040,9 @@ PyObject * } }
nk = PyDict_GET_SIZE(kwargs);[](#l1.11)
kwtuple = PyTuple_New(2 * nk); if (kwtuple == NULL) { @@ -5052,6 +5052,9 @@ PyObject * k = &PyTuple_GET_ITEM(kwtuple, 0); pos = i = 0; while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
/* We must hold strong references because keyword arguments can be[](#l1.19)
indirectly modified while the function is called:[](#l1.20)
see issue #2016 and test_extcall */[](#l1.21) Py_INCREF(k[i]);[](#l1.22) Py_INCREF(k[i+1]);[](#l1.23) i += 2;[](#l1.24)
@@ -5061,7 +5064,6 @@ PyObject * else { kwtuple = NULL; k = NULL;