0
0
mirror of https://github.com/python/cpython.git synced 2024-12-01 03:01:36 +01:00
cpython/Objects
Tim Peters 8383915031
GH-116939: Rewrite binarysort() (#116940)
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.
2024-03-21 22:27:25 -05:00
..
clinic gh-116621: Set manual critical section for list.extend (gh-116657) 2024-03-13 07:28:23 +09:00
mimalloc gh-115103: Delay reuse of mimalloc pages that store PyObjects (#115435) 2024-03-06 09:42:11 -05:00
stringlib
abstract.c
boolobject.c
bytearrayobject.c
bytes_methods.c
bytesobject.c
call.c
capsule.c
cellobject.c
classobject.c
codeobject.c gh-108716:: Remove _PyStaticCode_Init/Fini (#117141) 2024-03-22 01:27:48 +00:00
complexobject.c
descrobject.c
dictnotes.txt
dictobject.c gh-112075: Enable freeing with qsbr and fallback to lock on key changed (GH-116336) 2024-03-05 09:08:18 +00:00
enumobject.c
exception_handling_notes.txt
exceptions.c
fileobject.c
floatobject.c gh-116714: Handle errors correctly in PyFloat_GetInfo (#116715) 2024-03-13 12:38:03 +00:00
frame_layout.md
frameobject.c gh-115756: make PyCode_GetFirstFree an unstable API (GH-115781) 2024-03-19 09:20:38 +00:00
funcobject.c gh-117045: Add code object to function version cache (#117028) 2024-03-21 12:37:41 -07:00
genericaliasobject.c
genobject.c
iterobject.c
listobject.c GH-116939: Rewrite binarysort() (#116940) 2024-03-21 22:27:25 -05:00
listsort.txt GH-116939: Rewrite binarysort() (#116940) 2024-03-21 22:27:25 -05:00
lnotab_notes.txt
locations.md
longobject.c gh-110819: Fix ‘kind’ may be used uninitialized warning in longobject (#116599) 2024-03-12 13:50:06 +03:00
memoryobject.c
methodobject.c
moduleobject.c gh-116437: Use new C API PyDict_Pop() to simplify the code (GH-116438) 2024-03-07 11:21:08 +02:00
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 gh-76785: Drop PyInterpreterID_Type (gh-117101) 2024-03-21 17:15:02 +00:00
obmalloc.c gh-112075: Support freeing object memory via QSBR (#116344) 2024-03-08 09:56:36 -08:00
odictobject.c
picklebufobject.c
rangeobject.c
README
setobject.c gh-112069: Make sets thread-safe with the GIL disabled (#113800) 2024-03-08 16:25:34 -05:00
sliceobject.c
structseq.c GH-108362: Incremental Cycle GC (GH-116206) 2024-03-20 08:54:42 +00:00
tupleobject.c gh-116381: Remove bad specializations, add fail stats (GH-116464) 2024-03-08 00:21:21 +08:00
typeobject.c gh-115756: make PyCode_GetFirstFree an unstable API (GH-115781) 2024-03-19 09:20:38 +00:00
typeslots.inc
typeslots.py
typevarobject.c
unicodectype.c
unicodeobject.c gh-113964: Don't prevent new threads until all non-daemon threads exit (#116677) 2024-03-19 14:40:20 -04:00
unicodetype_db.h
unionobject.c
weakrefobject.c gh-111926: Simplify proxy creation logic (#116844) 2024-03-15 09:58:40 -04:00

Source files for various builtin objects