[issue37207] Use PEP 590 vectorcall to speed up calls to range(), list() and dict()

Inada Naoki report at bugs.python.org
Thu Sep 12 07:48:13 EDT 2019


Inada Naoki <songofacandy at gmail.com> added the comment:

$ ./python -m pyperf timeit --compare-to ./python-master 'dict()'
python-master: ..................... 89.9 ns +- 1.2 ns
python: ..................... 72.5 ns +- 1.6 ns

Mean +- std dev: [python-master] 89.9 ns +- 1.2 ns -> [python] 72.5 ns +- 1.6 ns: 1.24x faster (-19%)

$ ./python -m pyperf timeit --compare-to ./python-master -s 'import string; a=dict.fromkeys(string.ascii_lowercase); b=dict.fromkeys(string.ascii_uppercase)' -- 'dict(a, **b)'
python-master: ..................... 1.41 us +- 0.04 us
python: ..................... 1.53 us +- 0.04 us

Mean +- std dev: [python-master] 1.41 us +- 0.04 us -> [python] 1.53 us +- 0.04 us: 1.09x slower (+9%)

---

There is some overhead in old dict merging idiom.  But it seems reasonable compared to the benefit. LGTM.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37207>
_______________________________________


More information about the Python-bugs-list mailing list