-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: turn quicksort into introsort #7863
Conversation
another improvement one could do is use a good 3way partitioning scheme for integer sorts, the current simple partition does N swaps on equal elements. |
Introsort is regular quicksort but changing to a heapsort when not enough progress is made. This retains the good quicksort performance while changing the worst case runtime from O(N^2) to O(N*log(N))
Need to fix the worst case at line 753 in |
Java adopted dual-pivot quicksort, which looks to do better. The simplicity of the basic quicksort has a certain attraction. |
my though in not changing it was older numpy versions still have the worst case, and the worst case maybe includes an older numpy than the user expected ;) |
Maybe put a footnote on it and explanation about versions? I'm not sure on what the markup should be. |
Thanks Julian. |
fwiw https://pv.github.io/numpy-bench/#regressions?sort=1&dir=desc (best case seems worse --- also, the sort benchmarks in bench_function_base.py seem a bit silly as they only test this) |
hm I'm a moron, didn't translate the recursion to iterative properly ... |
#7871 should fix it, thanks for checking the benchmarks |
Introsort is regular quicksort but changing to a heapsort when not
enough progress is made. This retains the good quicksort performance
while changing the worst case runtime from O(N^2) to O(N*log(N))