[issue24076] sum() several times slower on Python 3 64-bit

Stefan Behnel report at bugs.python.org
Tue Sep 21 05:38:36 EDT 2021


Stefan Behnel <stefan_ml at behnel.de> added the comment:

Original:
$ ./python -m timeit -s 'd = list(range(2**61, 2**61 + 10000))' 'sum(d)'
500 loops, best of 5: 712 usec per loop
$ ./python -m timeit -s 'd = list(range(2**30, 2**30 + 10000))' 'sum(d)'
2000 loops, best of 5: 149 usec per loop
$ ./python -m timeit -s 'd = list(range(2**29, 2**29 + 10000))' 'sum(d)'
2000 loops, best of 5: 107 usec per loop
$ ./python -m timeit -s 'd = list(range(10000))' 'sum(d)'
2000 loops, best of 5: 107 usec per loop

New:
stefan at flup:~/ablage/software/Python/python-git$ ./python -m timeit -s 'd = list(range(2**61, 2**61 + 10000))' 'sum(d)'
500 loops, best of 5: 713 usec per loop
$ ./python -m timeit -s 'd = list(range(2**30, 2**30 + 10000))' 'sum(d)'
2000 loops, best of 5: 148 usec per loop
$ ./python -m timeit -s 'd = list(range(2**29, 2**29 + 10000))' 'sum(d)'
5000 loops, best of 5: 77.4 usec per loop
$ ./python -m timeit -s 'd = list(range(10000))' 'sum(d)'
5000 loops, best of 5: 77.2 usec per loop

Seems to be 28% faster for the single digit case and exactly as fast as before with larger integers.
Note that these are not PGO builds.

----------

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


More information about the Python-bugs-list mailing list