Skip to content

random.randint performance improvement #131435

Closed

Description

@dg-pb

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

Activity

  1. added
    performancePerformance or resource usage
    stdlibStandard Library Python modules in the Lib/ directory
    on Mar 19, 2025
  2. brianschubert commented on Mar 19, 2025

    @brianschubert
    Contributor

    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

  3. added a commit that references this issue on Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions