3 ms·
See CPython's https://github.com/python/cpython/blob/main/Objects/listsort.txt https://github.com/python/cpython/blob/main/Objects/listsort... for details about
by tim-peters 5y ago
See CPython's https://github.com/python/cpython/blob/main/Objects/listsort.txt https://github.com/python/cpython/blob/main/Objects/listsort...
for details about the sort. In fact, its "galloping" was inspired by a paper of which Demaine was a co-author (reference in the file already linked to).
CPython's lists are implemented as contiguous C arrays of pointers (to Python objects). Any way of grafting a tree-ish structure on top of that would be unacceptably wasteful of space and/or time. So sorting "gallops" over arrays because it's array-in, array-out.
- j-pb 5y agoThank you for the explanation!