Skip to content
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

RFC: quicksort refactor, addition of selectperm #12303

Merged
merged 2 commits into from
Jul 24, 2015
Merged

Conversation

kmsquire
Copy link
Member

This PR picks up where #10800 left off:

  1. extracts select_pivot! and partition! from quicksort
  2. reuses these among the different quicksort-like algorithms
  3. (from ENH: added selectperm and selectperm! based on new PartialQuickSort #10800) adds PartialQuickSort (originally from @carlobaldassi)
  4. (from ENH: added selectperm and selectperm! based on new PartialQuickSort #10800) adds selectperm, selectperm!
  5. For uniformity, switches select (and select!) to use PartialQuickSort

PartialQuickSort here handles both Int and OrdinalRange type parameters (which was not part of #10800).

It could (and probably should) be changed to only handle OrdinalRange parameters, which would simplify the code (removing one extra function), at the cost of 1 extra comparison per (recursive) call.

With limited testing, it seems that there are no performance regressions.

Cc: @spencerlyon2, @StefanKarpinski

@kmsquire kmsquire changed the title WIP: quicksort refactor, addition of selectperm RFC: quicksort refactor, addition of selectperm Jul 24, 2015
@StefanKarpinski
Copy link
Member

Nice.

@sglyon
Copy link
Contributor

sglyon commented Jul 24, 2015

This looks great. Anything else need to be done?

@kmsquire
Copy link
Member Author

The docs for PartialQuickSort need to be updated (it can handle any OrdinalRange). I would also like to try only having PartialQuickSort take an OrdinalRange, but I'm not sure I'll get to that today. It shouldn't change any functionality, but it would simplify the code some.

@StefanKarpinski
Copy link
Member

That could be done in a follow-on change, right? Seems better to do it separately then.

@StefanKarpinski
Copy link
Member

👍 merge at will!

* Break out select_pivot!, partition!, functions
* Share these among different quicksort variants
* Switch select to use PartialQuickSort
@kmsquire
Copy link
Member Author

Thanks! Updated docs, squashed, and will merge when CI turns green again.

I left @spencerlyon2's original commit in here. It passed CI previously, so I don't think it should be a problem.

kmsquire added a commit that referenced this pull request Jul 24, 2015
RFC: quicksort refactor, addition of selectperm
@kmsquire kmsquire merged commit 4c7a9d0 into master Jul 24, 2015
@kmsquire kmsquire deleted the kms/selectperm branch July 24, 2015 19:05
@sglyon
Copy link
Contributor

sglyon commented Jul 24, 2015

Thanks @kmsquire.

Hopefully it isn't an issue!

@kmsquire
Copy link
Member Author

:-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants