Message330839
Python's Timsort sometimes makes the same comparison twice. This leads to extra compares, which can hurt performance.
Python sorts several length-3 permutations in 4 steps, and the problem accumulates with bigger data. There are ~9,800 duplicate less-than checks when sorting a million randomly ordered numbers, and 24,386 wasted comparisons when sorting all permutations of length 8.
I've attached a patch to fix this issue. Feedback and improvements are appreciated. Speed seems roughly comparable, and should be much improved for expensive comparison functions.
The same problem occurs in the Chromium Browser, and probably other ports of Python's Timsort implementation. |
|
Date |
User |
Action |
Args |
2018-12-01 03:33:53 | dwyde | set | recipients:
+ dwyde, tim.peters |
2018-12-01 03:33:53 | dwyde | set | messageid: <1543635233.42.0.788709270274.issue35369@psf.upfronthosting.co.za> |
2018-12-01 03:33:53 | dwyde | link | issue35369 messages |
2018-12-01 03:33:52 | dwyde | create | |
|