This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lukasz.langa
Recipients Dennis Sweeney, gvanrossum, lukasz.langa, rhettinger, serhiy.storchaka
Date 2021-09-27.13:55:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1632750909.31.0.841045341031.issue45026@roundup.psfhosted.org>
In-reply-to
Content
Benchmarks for PGO builds on macOS 10.15 Catalina, Intel MBP 2018.

Like in Dennis' case, 20e3149c175a24466c7d1c352f8ff2c11effc489 is GH-27986 and cffa90a8b0057d7e7456571045f2fb7b9ceb426f is GH-28176. The difference is that `it_` benchmarks create the iterator on each execution. In this case the explicit iterator versions of the for-loop are indistinguishable from the ones using `range()` directly.

################
❯ python -m pyperf compare_to /tmp/20e3149c175a24466c7d1c352f8ff2c11effc489-2.json /tmp/cffa90a8b0057d7e7456571045f2fb7b9ceb426f-2.json -G
Slower (11):
- deque(it_100): 886 ns +- 22 ns -> 944 ns +- 12 ns: 1.07x slower
- list(iter(range(100))): 856 ns +- 17 ns -> 882 ns +- 17 ns: 1.03x slower
- for i in range(100000): pass: 2.20 ms +- 0.02 ms -> 2.26 ms +- 0.03 ms: 1.02x slower
- for i in range(10000): pass: 219 us +- 1 us -> 223 us +- 5 us: 1.02x slower
- for i in it_10000: pass: 219 us +- 1 us -> 223 us +- 5 us: 1.02x slower
- for i in it_100000: pass: 2.20 ms +- 0.03 ms -> 2.24 ms +- 0.04 ms: 1.02x slower
- for i in it_1000: pass: 20.1 us +- 0.1 us -> 20.4 us +- 0.4 us: 1.02x slower
- for i in range(1000): pass: 20.2 us +- 0.4 us -> 20.5 us +- 0.3 us: 1.02x slower
- for i in range(100): pass: 1.50 us +- 0.03 us -> 1.52 us +- 0.03 us: 1.01x slower
- list(iter(range(10))): 317 ns +- 9 ns -> 320 ns +- 6 ns: 1.01x slower
- for i in it_100: pass: 1.53 us +- 0.01 us -> 1.54 us +- 0.02 us: 1.01x slower

Faster (8):
- list(iter(range(100000))): 2.25 ms +- 0.05 ms -> 2.12 ms +- 0.03 ms: 1.06x faster
- deque(it_10000): 145 us +- 2 us -> 142 us +- 1 us: 1.03x faster
- list(iter(range(1000))): 12.6 us +- 0.2 us -> 12.3 us +- 0.1 us: 1.02x faster
- deque(it_100000): 1.47 ms +- 0.01 ms -> 1.45 ms +- 0.02 ms: 1.02x faster
- for i in it_10: pass: 309 ns +- 6 ns -> 304 ns +- 3 ns: 1.02x faster
- list(iter(range(10000))): 147 us +- 2 us -> 145 us +- 2 us: 1.01x faster
- deque(it_10): 544 ns +- 19 ns -> 537 ns +- 10 ns: 1.01x faster
- deque(it_1000): 12.6 us +- 0.2 us -> 12.5 us +- 0.2 us: 1.01x faster

Benchmark hidden because not significant (1): for i in range(10): pass

Geometric mean: 1.00x slower
################

The results look like a wash here. Let me compare both to `main`.
History
Date User Action Args
2021-09-27 13:55:09lukasz.langasetrecipients: + lukasz.langa, gvanrossum, rhettinger, serhiy.storchaka, Dennis Sweeney
2021-09-27 13:55:09lukasz.langasetmessageid: <1632750909.31.0.841045341031.issue45026@roundup.psfhosted.org>
2021-09-27 13:55:09lukasz.langalinkissue45026 messages
2021-09-27 13:55:09lukasz.langacreate