This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dwyde
Recipients dwyde, tim.peters
Date 2018-12-01.03:33:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543635233.42.0.788709270274.issue35369@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-12-01 03:33:53dwydesetrecipients: + dwyde, tim.peters
2018-12-01 03:33:53dwydesetmessageid: <1543635233.42.0.788709270274.issue35369@psf.upfronthosting.co.za>
2018-12-01 03:33:53dwydelinkissue35369 messages
2018-12-01 03:33:52dwydecreate