4 ms·
Simple min and max on my computer reliably seems to take less time than the sorted solution, and also makes more sense to read. This is what I would intuitively
by parennoob 12y ago
Simple min and max on my computer reliably seems to take less time than the sorted solution, and also makes more sense to read. This is what I would intuitively expect anyway with the overhead of making the array.
>>> timeit.timeit('x=4; y=3; x, y = sorted([x, y])')
0.49517297744750977
>>> timeit.timeit('x=4; y=3; x = min(x,y); y = max(x, y)')
0.2774021625518799