Message361198
The code for listiter_next() and listreviter_next() is almost the same.
The main difference that the code for reversed saves the index to Py_ssize_t variable. Maybe that causes a 32-bit to 64-bit conversion and back. The change was made on 30 March 2016 in fbb1c5ee068d209e33f6e15ecb4821d5d8b107fa
Another possible cause is that this is just a random build outcome due to PGO or incidental branch mis-prediction from aliasing (as described in https://stackoverflow.com/a/17906589/1001643 ).
On the python.org mac 64-bit build, I'm not seeing any difference, so this is unique to the Windows 32-bit build.
$ python3.7 -m timeit -r11 -s "a = list(range(250)) * 4000" "list(iter(a))"
100 loops, best of 11: 3.08 msec per loop
$ python3.7 -m timeit -r11 -s "a = list(range(250)) * 4000" "list(reversed(a))"
100 loops, best of 11: 3.04 msec per loop
$ python3.8 -m timeit -r11 -s "a = list(range(250)) * 4000" "list(iter(a))"
100 loops, best of 11: 3.07 msec per loop
$ python3.8 -m timeit -r11 -s "a = list(range(250)) * 4000" "list(reversed(a))"
100 loops, best of 11: 3.01 msec per loop |
|
Date |
User |
Action |
Args |
2020-02-01 22:13:40 | rhettinger | set | recipients:
+ rhettinger, vstinner, SilentGhost, serhiy.storchaka, Stefan Pochmann |
2020-02-01 22:13:40 | rhettinger | set | messageid: <1580595220.13.0.857817197434.issue39521@roundup.psfhosted.org> |
2020-02-01 22:13:40 | rhettinger | link | issue39521 messages |
2020-02-01 22:13:39 | rhettinger | create | |
|