8000 Fixes in sorting descriptions (GH-18317) · python/cpython@24e5ad4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 24e5ad4

Browse files
authored
Fixes in sorting descriptions (GH-18317)
Improvements in listsort.txt and a comment in sortperf.py. Automerge-Triggered-By: @csabella
1 parent 4b52416 commit 24e5ad4

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Lib/test/sortperf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def tabulate(r):
134134
L = list(range(half - 1, -1, -1))
135135
L.extend(range(half))
136136
# Force to float, so that the timings are comparable. This is
137-
# significantly faster if we leave tham as ints.
137+
# significantly faster if we leave them as ints.
138138
L = list(map(float, L))
139139
doit(L) # !sort
140140
print()

Objects/listsort.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,13 @@ So merging is always done on two consecutive runs at a time, and in-place,
319319
although this may require some temp memory (more on that later).
320320

321321
When a run is identified, its base address and length are pushed on a stack
322-
in the MergeState struct. merge_collapse() is then called to see whether it
323-
should merge it with preceding run(s). We would like to delay merging as
324-
long as possible in order to exploit patterns that may come up later, but we
325-
like even more to do merging as soon as possible to exploit that the run just
326-
found is still high in the memory hierarchy. We also can't delay merging
327-
"too long" because it consumes memory to remember the runs that are still
328-
unmerged, and the stack has a fixed size.
322+
in the MergeState struct. merge_collapse() is then called to potentially
323+
merge runs on that stack. We would like to delay merging as long as possible
324+
in order to exploit patterns that may come up later, but we like even more to
325+
do merging as soon as possible to exploit that the run just found is still
326+
high in the memory hierarchy. We also can't delay merging "too long" because
327+
it consumes memory to remember the runs that are still unmerged, and the
328+
stack has a fixed size.
329329

330330
What turned out to be a good compromise maintains two invariants on the
331331
stack entries, where A, B and C are the lengths of the three rightmost not-yet
@@ -739,7 +739,7 @@ slice (leaving off both endpoints) (2**(k-1)-1)+1 through (2**k-1)-1
739739
inclusive = 2**(k-1) through (2**k-1)-1 inclusive, which has
740740
(2**k-1)-1 - 2**(k-1) + 1 =
741741
2**k-1 - 2**(k-1) =
742-
2*2**k-1 - 2**(k-1) =
742+
2*2**(k-1)-1 - 2**(k-1) =
743743
(2-1)*2**(k-1) - 1 =
744744
2**(k-1) - 1
745745
elements.

0 commit comments

Comments
 (0)
0