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

Consistent use of valid index check #99761

Open
eendebakpt opened this issue Nov 24, 2022 · 0 comments
Open

Consistent use of valid index check #99761

eendebakpt opened this issue Nov 24, 2022 · 0 comments
Labels
type-feature A feature request or enhancement

Comments

@eendebakpt
Copy link
Contributor

eendebakpt commented Nov 24, 2022

Feature or enhancement

In listobject.c there is an optimization to check whether an index is valid (e.g. 0 <= index < N) using a single comparison. The same optimization is not used in other files such as tupleobject.c.

By replacing index checks with a single macro that includes the optimization we have consistency in the code and have the optimized check for all index checks.

Previous discussion

Idea first mentioned at faster-cpython/ideas#498

Linked PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant