Skip to content

Precompute Python Requirements Candidate Lookup#13656

Merged
notatallshaw merged 2 commits intopypa:mainfrom
notatallshaw:pre-compute-Python-Requirement-speicifier
Nov 19, 2025
Merged

Precompute Python Requirements Candidate Lookup#13656
notatallshaw merged 2 commits intopypa:mainfrom
notatallshaw:pre-compute-Python-Requirement-speicifier

Conversation

@notatallshaw
Copy link
Copy Markdown
Member

@notatallshaw notatallshaw commented Nov 19, 2025

In pathological backtracking this can end up being called millions of times.

With this change, in pathological scenarios, there is significantly less calling into packaging. Running one pathological example for example it goes from ~7.5 million Version objects being created to ~3.3 million Version objects being created. This is non-trivial and can be a ~20-25% saving in CPU time.

See the call graphs below:

Details

Before:

callgraph_before

After:

callgraph_after

Copy link
Copy Markdown
Member

@ichard26 ichard26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@notatallshaw notatallshaw merged commit e18a82f into pypa:main Nov 19, 2025
28 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants