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

random.randint performance improvement #131435

Closed
dg-pb opened this issue Mar 18, 2025 · 1 comment
Closed

random.randint performance improvement #131435

dg-pb opened this issue Mar 18, 2025 · 1 comment
Labels
performance Performance or resource usage stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@dg-pb
Copy link
Contributor

dg-pb commented Mar 18, 2025

Feature or enhancement

Proposal:

randint is a commonly needed function, but it is fairly slow (compared to random.random).
Maybe it would be good to port couple of lower level functions to C.
But for the time being, this small edit results in 20% better performance by avoiding unnecessary abstractions.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@dg-pb dg-pb added the type-feature A feature request or enhancement label Mar 18, 2025
@picnixz picnixz added performance Performance or resource usage stdlib Python modules in the Lib dir labels Mar 19, 2025
@brianschubert
Copy link
Contributor

brianschubert commented Mar 19, 2025

Maybe it would be good to port couple of lower level functions to C.

Adding C implementations for random has been rejected before. See #126149 for previous discussion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance or resource usage stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

4 participants