Skip to content

Optimize keep_top_bit() in heapq module by using _Py_bit_length() #124165

@visitorckw

Description

@visitorckw

Feature or enhancement

Proposal:

The keep_top_bit() function in the heapq module currently shifts bits manually to determine the top bit. This can be optimized by using the _Py_bit_length() function, which improves efficiency, especially on hardware that supports specific instructions like bsr on x86 architecture.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions