[issue38328] Speed up the creation time of constant list literals.
Serhiy Storchaka
report at bugs.python.org
Fri Oct 4 13:56:00 EDT 2019
Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:
Great! I withdrew the original proposition in issue33325 because the part of the optimization was not so good as I expected. But this part is good.
$ ./python -m timeit "[$(seq -s, 10)]"
5000000 loops, best of 5: 75.5 nsec per loop
$ ./python -m timeit "[*($(seq -s, 10))]"
5000000 loops, best of 5: 57.2 nsec per loop
Would you consider to optimize also creating a set of constants?
$ ./python -m timeit "{$(seq -s, 10)}"
2000000 loops, best of 5: 186 nsec per loop
$ ./python -m timeit -s "a = frozenset(($(seq -s, 10)))" "{*a}"
2000000 loops, best of 5: 116 nsec per loop
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38328>
_______________________________________
More information about the Python-bugs-list
mailing list