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

Use shared helper function for faster index range checks #120176

Closed
lgeiger opened this issue Jun 6, 2024 · 1 comment
Closed

Use shared helper function for faster index range checks #120176

lgeiger opened this issue Jun 6, 2024 · 1 comment

Comments

@lgeiger
Copy link
Contributor

lgeiger commented Jun 6, 2024

#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

@serhiy-storchaka
Copy link
Member

This is a duplicate of #72583. This idea was already rejected.

@serhiy-storchaka serhiy-storchaka closed this as not planned Won't fix, can't repro, duplicate, stale Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants