← 返回首页
Consistent use of valid index check · Issue #99761 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

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

Provide feedback

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

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

Consistent use of valid index check #99761

New issue
New issue

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

    Fields

    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

    • Open in GitHub Copilot app

    Footer

    © 2026 GitHub, Inc.