Skip to content

ENH: Port numpy.random extension modules to the Limited API and update limited_api to 3.13 - #32112

Merged
rgommers merged 3 commits into
numpy:mainfrom
prathamhole14:random_limited_api
Jul 29, 2026
Merged

rgommers merged 3 commits into
numpy:mainfrom
prathamhole14:random_limited_api

Conversation

@prathamhole14

@prathamhole14 prathamhole14 commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

PR summary

As titled, see comments for explanation.
Darft since I want to confirm if CI is okay with this, Will share benchmark soon.

Benchmarks: https://gist.github.com/prathamhole14/31a7b0d1b0a76b73cad028ab6a508446

Related to: #31913

AI Disclosure

For comments and some research.

@prathamhole14
prathamhole14 marked this pull request as ready for review July 27, 2026 09:54
@rkern

rkern commented Jul 27, 2026

Copy link
Copy Markdown
Member

These look fine to me as far as the impact on np.random is concerned. I'll leave the actual approval review to someone who is tracking the Limited API work.

@rgommers rgommers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @prathamhole14. Call overhead of 8-19% and no impact for large array operations is what I'd expect, and seems perfectly acceptable.

Undoing the usage of PyMem_RawMalloc & co. doesn't look like a good idea to me, that impacts performance and use of profilers. If those functions were added to the Limited API in 3.13, then I suggest to just target 3.13 as the minimum Python version when targeting the Stable ABI. We're only 5 months off from dropping 3.12 anyway, and there's no real downside there.

@prathamhole14

Copy link
Copy Markdown
Member Author

Hi Ralf, thank you for the review! yes I agree with your suggestion and it also makes changes cleaner. Although I am pushing what you asked for I am open to revert back if required. Thanks

@prathamhole14 prathamhole14 changed the title ENH: Port numpy.random extension modules to the Limited API ENH: Port numpy.random extension modules to the Limited API and update limited_api to 3.13 Jul 28, 2026

@rgommers rgommers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks much better to me now, thanks!

@ngoldbaum ngoldbaum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! We'll look at tests in #32130

@ngoldbaum

Copy link
Copy Markdown
Member

@rgommers I think you might need to approve to clear the merge block

@rgommers rgommers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM now, thanks @prathamhole14 and reviewers

@rgommers
rgommers merged commit 5895a4c into numpy:main Jul 29, 2026
91 checks passed
@rgommers rgommers added this to the 2.6.0 Release milestone Jul 29, 2026
@prathamhole14
prathamhole14 deleted the random_limited_api branch July 29, 2026 15:52
prathamhole14 added a commit to prathamhole14/numpy that referenced this pull request Jul 29, 2026
numpy.random was ported to the Limited API in numpygh-32112, after this branch
was created; the check is bidirectional, so those nine modules have to be
listed here.
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.

4 participants