FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ENH: ArrayMethod sorts for builtin dtypes by MaanasArora · Pull Request #31273 · numpy/numpy · GitHub

/ numpy Public

ENH: ArrayMethod sorts for builtin dtypes - #31273

Closed
MaanasArora wants to merge 2 commits into
numpy:mainfrom
MaanasArora:builtin-sort-methods
Closed

ENH: ArrayMethod sorts for builtin dtypes#31273
MaanasArora wants to merge 2 commits into
numpy:mainfrom
MaanasArora:builtin-sort-methods

Conversation

MaanasArora commented Apr 19, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Adds new-style sorting and argsorting array-methods (#29737) to built-in NumPy dtypes (bools, integers, floats, dates; there are methods for string/unicode but not registered yet). This allows the new path in PyArray_Sort to be functional for these, which will enable writing descending sorts soon after this. ping @seberg @mhvk - thanks!

Happy to add descending sorts in this PR if it doesn't make this too hard to read, there are just a lot of (repetitive) lines with this direction. I tried reducing duplication, but seems unfortunately hard to do because of the C++ templating, and I actually somewhat prefer this so far just to keep the new/old sorts quite separate.

Still have to check the resolve descriptors setup and string/unicode quirks, but otherwise this is basically complete.

AI Disclosure

I used Claude to fill in the *sort_loop functions with the new signatures. I gave it the bool + existing code for each (arg)sort kind and let it generate the rest, then looked briefly but didn't find any inconsistencies, but will keep an eye.

MaanasArora changed the title WIP, ENH: ArrayMethod sorts for builtin dtypes ENH: ArrayMethod sorts for builtin dtypes Apr 19, 2026
return -1;
}
NPY_DT_SLOTS(dtypemeta)->sort_meth = sort_method_@name@->method;
Py_INCREF(sort_method_@name@->method);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Leaking, but causes a segfault when I decref...

Copy link
Copy Markdown
Contributor Author

Sorry, totally overcomplicated this! Closing this in favor of the far smaller alternative in #31278.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL