logoalt Hacker News

jlduggertoday at 6:02 PM1 replyview on HN

Uh, what is going on with this benchmark?

Why is M so big? Why does it cross the maxint boundary? Why is constructing the list comprehension part of the benchmark? Why are we summing the set? Why are we only measuring 5 values for n?


Replies

brody_hamertoday at 10:00 PM

Yea if I cast the large calculated integers to strings, performance is O(1)

`values = [str(i * M) for i in range(1, n + 1)]`

or

`values = [i * M % 1_000_000_000_000_000 for i in range(1, n + 1)]`