2 ms·
The difference between merge sort and tim sort is not "removing a check"; timsort is actually a different algorithm. In the ordinary sense of the word, there is
by scythe 12y ago
The difference between merge sort and tim sort is not "removing a check"; timsort is actually a different algorithm. In the ordinary sense of the word, there is no check. In fact, the use of insertion sort is most important to speed up sorting random data, because the real advantage of insertion sort is that for small enough chunks -- anything that fits in a few cache lines -- the amount you save on comparisons vastly exceeds the amount you spend on swapping. Most well-written sort functions use insertion sort at small enough sizes.
The adaptive speedup in timsort does not come from adopting ideas in insertion sort; rather, it comes from strand sort.
http:// http:// en.wikipedia.org/wiki/Strand_sort
As to the speedup, who knows? As you've stated, this is an apples-to-oranges comparison. It depends on the Python vs NumPy object model, and it's pretty suspicious to see mergesort beating quicksort.