The inclusion of ”continue” in the non-lol version is pointless and obscures the actual reason for the difference: the addition of the non-pointless ”continue” in the lol version.
As other comments point out, this construct can be replaced by a cmov instruction:
if a > b:
b = a
The following construct however, cannot be replaced by cmov:
if a > b:
b = a
continue
Only by first eliminating the pointless "continue" is this replacement valid. But by including it, you can make it look like it's the 'print("lol")' is what makes the difference, which is only true lexically.
Thanks! In that case, I have to say I'm surprised. I assumed the code generated for the loop would have an instructions that branches, so adding another branching instruction could only hurt (edit: not necessarily a lot), but apparently my intuition is wrong.
I'm curious if the performance difference noted in the article happens on Intel/AMD as well...
It is there to skip the print("lol") in the second version if the condition is true. Since the array is sorted in ascending order, it will be true for every value, and that print is never be executed.
As other comments point out, this construct can be replaced by a cmov instruction:
The following construct however, cannot be replaced by cmov: Only by first eliminating the pointless "continue" is this replacement valid. But by including it, you can make it look like it's the 'print("lol")' is what makes the difference, which is only true lexically.