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

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

@MaanasArora MaanasArora commented Apr 19, 2026

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 MaanasArora changed the title WIP, ENH: ArrayMethod sorts for builtin dtypes ENH: ArrayMethod sorts for builtin dtypes Apr 19, 2026

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.

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

@MaanasArora

Copy link
Copy Markdown
Contributor Author

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