-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH, API: New sorting mechanism for DType API #28516
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
Open
MaanasArora
wants to merge
30
commits into
numpy:main
Choose a base branch
from
MaanasArora:enh/faster-string-sorting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
4700c13
ENH: Allocate lock only once in StringDType quicksort
MaanasArora 5fb0b5f
ENH: Add dtype slots for sorting and begin integration
MaanasArora 76be21b
MAINT: Rename sort compare slot access function
MaanasArora 59590d2
ENH: Add dtype slot sorting functionality support to all sort kinds
MaanasArora b89accd
ENH: Add descending flag to internal sorting functions
MaanasArora a437eb9
MAINT: Improve get dtype sort compare function name
MaanasArora aa63d11
MAINT: Fix doc typo
MaanasArora 16e95a2
MAINT: Error out when non-legacy dtype has no sort_compare function
MaanasArora 42e76d6
DOC: Add release notes for new dtype sorting API
MaanasArora 88636cc
DOC: Add doc for sort compare slot in release notes
MaanasArora 9d14ec1
DOC: Add note for potential deprecation of sort arrfuncs in release note
MaanasArora a556455
MAINT: Reorder dtype slots to prevent changing existing slot numbers
MaanasArora 3c0957e
BUG: Error on missing `sort_compare` slot only when dtype is privatel…
MaanasArora 9506798
DOC: Add C-API documentation for new sorting slots
MaanasArora 6ce5351
ENH: Replace array object with context and auxdata in sortfunc signat…
MaanasArora 96a53b2
BUG: Fix unnecessarily private function call due to underscore typo
MaanasArora 9a2b100
MAINT: Fix whitespace typos
MaanasArora 8d4c75d
ENH: Allow flexible sorting compare for arr or descr in npy_sort func…
MaanasArora 50988ba
ENH: Add new sort func implementations and use in stringdtype
MaanasArora ca5797e
DOC: Fix missing newline in ctype doc
MaanasArora 95cfd8f
DOC: Add sortfunc typedef docs
MaanasArora 6dd4f4c
DOC: Fix missing newline in ctype doc
MaanasArora 4fa813c
ENH: Define SortCompareFunc type
MaanasArora 894911e
Update dtype sorting signatures: move context, move out auxdata to ge…
MaanasArora 57687ac
MAINT: Check error in Get(Arg)SortFunc using return value
MaanasArora 0edb4ea
DOC: Add missing newlines to c-types in array.rst
MaanasArora 167301e
MAINT: Rename new sort funcs and restore older names for existing pub…
MaanasArora e6b8c1e
MAINT: Rename start pointer in new sort func documentation to data
MaanasArora 579c351
ENH: Add flags to new get_(arg)sort_function
MaanasArora d854b00
DOC: Mention new sort func buffers to be contiguous
MaanasArora File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
ENH: Define SortCompareFunc type
- Loading branch information
commit 4fa813c35d08b526e1f1bc37f8f29e0de93181ed
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The naming is a bit weird here, but I didn't want to disturb the original type as it's used a lot. I think the
SortCompareFunc
should still be a unique type so will do that (even if only a clone of this type).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have slightly mixed feelings. On the one hand, I think this is the pragmatic thing to have.
On the other hand, we could also look this function from the
np.less_than
ornp.great_than
ufunc to implement sorting, I think.(The problem there is still how to deal with unordered elements, a compare ufunc would work better...)
But, on the other hand, it seems pragmatic even if it won't work well e.g. for structured dtypes (performance issues), it will always work and provides an easy entry-point (we can also use this to define default comparison ufuncs).
So overall, I think I end up at just doing this, although I could imaging punting if we don't need it for
StringDType
(I suspect we do, though).Would like to hear if @ngoldbaum has an opinion.
(A neater future path would also be if this was more of a header-only code binding generator job with us making the sorting patterns available maybe. I.e. if this was defined in a C++ class and our sort code available, the DType could compile the full loop and avoid calling such a helper everywhere.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is fine, if only because it exists right now 😄