New submission from Eric Lippert <[email protected]>:
In _PyFunction_FastCallDict we have local nk assigned to be the size of a
dictionary, and then local i is assigned to twice the size of the same
dictionary, and then nk is assigned to half of i, which it already is:
nk = (kwargs != NULL) ? PyDict_GET_SIZE(kwargs) : 0;
if (nk != 0) {
...
pos = i = 0;
while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
...
i += 2;
}
nk = i / 2;
I am attempting to understand the performance characteristics of this hot path,
and I spent far too long trying to figure out why nk was being assigned a value
it already has. :)
I propose that the redundant store be replaced with an assertion that i/2 is
equal to nk.
I will submit a pull request presently.
----------
components: Interpreter Core
messages: 324395
nosy: Eric Lippert
priority: normal
severity: normal
status: open
title: Redundant store can be removed from _PyFunction_FastCallDict
type: enhancement
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue34551>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com