mirror of
https://github.com/python/cpython.git
synced 2024-12-01 03:01:36 +01:00
8383915031
Rewrote binarysort() for clarity. Also changed the signature to be more coherent (it was mixing sortslice with raw pointers). No change in method or functionality. However, I left some experiments in, disabled for now via `#if` tricks. Since this code was first written, some kinds of comparisons have gotten enormously faster (like for lists of floats), which changes the tradeoffs. For example, plain insertion sort's simpler innermost loop and highly predictable branches leave it very competitive (even beating, by a bit) binary insertion when comparisons are very cheap, despite that it can do many more compares. And it wins big on runs that are already sorted (moving the next one in takes only 1 compare then). So I left code for a plain insertion sort, to make future experimenting easier. Also made the maximum value of minrun a `#define` (``MAX_MINRUN`) to make experimenting with that easier too. And another bit of `#if``-disabled code rewrites binary insertion's innermost loop to remove its unpredictable branch. Surprisingly, this doesn't really seem to help overall. I'm unclear on why not. It certainly adds more instructions, but they're very simple, and it's hard to be believe they cost as much as a branch miss. |
||
---|---|---|
.. | ||
clinic | ||
mimalloc | ||
stringlib | ||
abstract.c | ||
boolobject.c | ||
bytearrayobject.c | ||
bytes_methods.c | ||
bytesobject.c | ||
call.c | ||
capsule.c | ||
cellobject.c | ||
classobject.c | ||
codeobject.c | ||
complexobject.c | ||
descrobject.c | ||
dictnotes.txt | ||
dictobject.c | ||
enumobject.c | ||
exception_handling_notes.txt | ||
exceptions.c | ||
fileobject.c | ||
floatobject.c | ||
frame_layout.md | ||
frameobject.c | ||
funcobject.c | ||
genericaliasobject.c | ||
genobject.c | ||
iterobject.c | ||
listobject.c | ||
listsort.txt | ||
lnotab_notes.txt | ||
locations.md | ||
longobject.c | ||
memoryobject.c | ||
methodobject.c | ||
moduleobject.c | ||
namespaceobject.c | ||
object_layout_312.gv | ||
object_layout_312.png | ||
object_layout_full_312.gv | ||
object_layout_full_312.png | ||
object_layout.md | ||
object.c | ||
obmalloc.c | ||
odictobject.c | ||
picklebufobject.c | ||
rangeobject.c | ||
README | ||
setobject.c | ||
sliceobject.c | ||
structseq.c | ||
tupleobject.c | ||
typeobject.c | ||
typeslots.inc | ||
typeslots.py | ||
typevarobject.c | ||
unicodectype.c | ||
unicodeobject.c | ||
unicodetype_db.h | ||
unionobject.c | ||
weakrefobject.c |
Source files for various builtin objects