Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use shared helper function for faster index range checks #120176

Copy link
Copy link

Description

@lgeiger
Issue body actions

#9784 (discussed in #72583 and #67741) introduced a helper function to reduce the number of comparisons in list index range checks (see https://godbolt.org/z/jM8oexT1d).

The same pattern can be applied in many other places in the code base like in arraymodule.c, mmapmodule.c, bytearrayobject.c, etc.

I'd propose to extract this helper function into a header and start using it in more places for index range checks. internal/pycore_abstract.h seems like it might be a decent place to put this helper in.

I'm happy to make a PR if people think a micro optimisation like this justifies the code churn, but let me know if I'm missing something.

Linked PRs

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.