A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-March/138729.html below:

[Python-Dev] Tunning binary insertion sort algorithm in Timsort.

[Python-Dev] Tunning binary insertion sort algorithm in Timsort. [Python-Dev] Tunning binary insertion sort algorithm in Timsort.Armin Rigo arigo at tunes.org
Wed Mar 11 09:26:12 CET 2015
Hi Tim,

On 10 March 2015 at 18:22, Tim Peters <tim.peters at gmail.com> wrote:
> 1. Merge "2 at a time" instead of just 1.  That is, first "sort" the
> next 2 elements to be merged (1 compare and a possible swap).  Then
> binary search to find where the smaller belongs, and a shorter binary
> search to find where the larger belongs.  Then shift both into place.

Good idea, but when I tried that it seemed to increase the total
number of comparisons (on random inputs with only up to 136 items).
The increase is on the order of 5%.  I'm not sure reduced data
movement can compensate for that in Python.

Test and code available here:
https://bitbucket.org/arigo/arigo/src/default/hack/pypy-hack/list_sort/

The change to insert two items at a time is here:
https://bitbucket.org/arigo/arigo/commits/68e04d143dc242cfd9e3934451321f685a68a8e2

(This is taken straight from PyPy's code.)


A bientôt,

Armin.
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4