Why is max slower than sort?
Why is max slower than sort? Question: I’ve found that max is slower than the sort function in Python 2 and 3. Python 2 $ python -m timeit -s ‘import random;a=range(10000);random.shuffle(a)’ ‘a.sort();a[-1]’ 1000 loops, best of 3: 239 usec per loop $ python -m timeit -s ‘import random;a=range(10000);random.shuffle(a)’ ‘max(a)’ 1000 loops, best of 3: 342 …