If I want to compare two number in python:
One way is by max():
r = max(r,a-b)
the other way is in this way:
r = a-b if a-b>r else r
And the second way is faster than the first way, this performance puzzles me a lot. Because the max() function must have been optimized, and the second way may compute (a-b) for two times, I think. Could anyone explain me why?