Skip to content

perf(utils): precompile the wheel project-name pattern - #1256

Merged
henryiii merged 1 commit into
pypa:mainfrom
henryiii:perf/utils-precompile-regex
Jun 13, 2026
Merged

henryiii merged 1 commit into
pypa:mainfrom
henryiii:perf/utils-precompile-regex

Conversation

@henryiii

Copy link
Copy Markdown
Contributor

ðŸĪ– AI text below ðŸĪ–

The project-name check in parse_wheel_filename was the one remaining inline re.match in a module where every other pattern is compiled at import time. The pattern is now a module-level _wheel_name_regex, and the redundant \d inside \w is dropped (equivalence verified across ASCII, digit, unicode-word, and rejection cases — no behavior change).

The gain is small since re caches compilations internally and this only skips the cache lookup: parse_wheel_filename goes from 1.41Ξs to 1.31Ξs per call (timeit, Python 3.14, Apple M5 Pro). Mostly a consistency cleanup with a minor win.

Part of #1239.

ðŸĪ– Generated with Claude Code

Every other pattern in this module is compiled at import time; the
project-name check in parse_wheel_filename was the one inline re.match
left. The redundant \d inside \w is also dropped; the match behavior
is unchanged.

Assisted-by: ClaudeCode:claude-fable-5
@henryiii
henryiii marked this pull request as ready for review June 12, 2026 19:27
@henryiii
henryiii merged commit d2ac6ba into pypa:main Jun 13, 2026
59 checks passed
@henryiii
henryiii deleted the perf/utils-precompile-regex branch June 13, 2026 03:12
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

Successfully merging this pull request may close these issues.

2 participants