Skip to content

Commit 3ddb856

Browse files
committed
Fixed new typos, added a little info about ~sort versus "hint"s.
1 parent 8f3afc7 commit 3ddb856

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Objects/listsort.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ Comparison with Python's Samplesort Hybrid
113113
4377402 262437 262459 416347 1457945 524286
114114
1.99% 1577.82% -0.06% 967.83% -24.01% 774.44%
115115

116-
524288 9205096 9453356 9408463 524468 9441930 2218577 9692015
117-
9278734 524580 524633 837947 2916107 1048574
116+
524288 9205096 9453356 9408463 524468 9441930 2218577 9692015
117+
9278734 524580 524633 837947 2916107 1048574
118118
1.88% 1693.52% -0.03% 1026.79% -23.92% 824.30%
119119

120120
1048576 19458756 19950272 19838588 1048766 19912134 4430649 20434212
@@ -431,7 +431,7 @@ at-a-time mode.
431431

432432
A refinement: The MergeState struct contains the value of min_gallop that
433433
controls when we enter galloping mode, initialized to MIN_GALLOP.
434-
merge_lo() and merge_hi() adjust this higher when gallooping isn't paying
434+
merge_lo() and merge_hi() adjust this higher when galloping isn't paying
435435
off, and lower when it is.
436436

437437

@@ -549,7 +549,7 @@ that merge_lo and merge_hi adjust: the longer we stay in galloping mode,
549549
the smaller min_gallop gets, making it easier to transition back to
550550
galloping mode (if we ever leave it in the current merge, and at the
551551
start of the next merge). But whenever the gallop loop doesn't pay,
552-
min_gallop is increased by one, making it harder to transition to back
552+
min_gallop is increased by one, making it harder to transition back
553553
to galloping mode (and again both within a merge and across merges). For
554554
random data, this all but eliminates the gallop penalty: min_gallop grows
555555
large enough that we almost never get into galloping mode. And for cases
@@ -576,6 +576,12 @@ probably a better guess at the final result than either 0 or 9999. But
576576
it's unclear how to generalize that intuition usefully, and merging of
577577
wildly unbalanced runs already enjoys excellent performance.
578578

579+
~sort is a good example of when balanced runs could benefit from a better
580+
hint value: to the extent possible, this would like to use a starting
581+
offset equal to the previous value of acount/bcount. Doing so saves about
582+
10% of the compares in ~sort. However, doing so is also a mixed bag,
583+
hurting other cases.
584+
579585

580586
Comparing Average # of Compares on Random Arrays
581587
------------------------------------------------

0 commit comments

Comments
 (0)