Skip to content

Avoid version set construction in get applicable candidates#13916

Merged
notatallshaw merged 2 commits intopypa:mainfrom
notatallshaw:avoid-version-set-construction-in-get-applicable-candidates
Apr 17, 2026
Merged

Avoid version set construction in get applicable candidates#13916
notatallshaw merged 2 commits intopypa:mainfrom
notatallshaw:avoid-version-set-construction-in-get-applicable-candidates

Conversation

@notatallshaw
Copy link
Copy Markdown
Member

packaging 26.1 adds a new key parameter on their filter methods, this allows a packaging specifier to directly filter candidate objects without needing to do any pre-work or construct a set of versions, which can be a hot spot of working during long resolutions.

I'm not sure what the real world performance impact will be, because constructing and retrieving the hash of a version also got a lot faster in 26.1: pypa/packaging#1156 (comment), but either way it's work we no longer needed to be doing.

@notatallshaw
Copy link
Copy Markdown
Member Author

P.S, I think there's a very subtle bug, and further performance wins, in get_applicable_candidates, but this is just meant to be a minimal PR to use the new key=.

@notatallshaw notatallshaw added this to the 26.1 milestone Apr 15, 2026
Copy link
Copy Markdown
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

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

Even if this does not improve performance significantly, this is easier to read 👍

@notatallshaw notatallshaw merged commit a843a4d into pypa:main Apr 17, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants