Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork34k
gh-143658: importlib.metadata: Usestr.translate to improve performance ofimportlib.metadata.Prepared.normalized#143660
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-143658: importlib.metadata: Usestr.translate to improve performance ofimportlib.metadata.Prepared.normalized#143660
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Co-Authored-By: Henry Schreiner <henryschreineriii@gmail.com>
translate to improve performance ofcanonicalize_nametranslate to improve performance ofcanonicalize_nameMisc/NEWS.d/next/Library/2026-01-10-15-40-57.gh-issue-143658.Ox6pE5.rst OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
translate to improve performance ofcanonicalize_namestr.translate to improve performance ofimportlib.metadata.Prepared.normalizedCo-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
picnixz left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Do we have tests actually? if not, maybe it'd be good to add some.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
johnslavik left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Small ideas
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Bartosz Sławecki <bartosz@ilikepython.com>
Uh oh!
There was an error while loading.Please reload this page.
cbf9b8c intopython:mainUh oh!
There was an error while loading.Please reload this page.
hugovk commentedJan 20, 2026
See#144083 for a followup. |
Uh oh!
There was an error while loading.Please reload this page.
We can apply@henryiii's improvement to
packaginginpypa/packaging#1030 (see alsohttps://iscinumpy.dev/post/packaging-faster/) to improve the performance ofcanonicalize_nameand make it ~3.7 times faster.Benchmark
Run
Prepared.normalize(n)on every name in PyPI:Benchmark data can be found athttps://gist.github.com/hugovk/efdbee0620cc64df7b405b52cf0b6e42
Before
With optimisations:
After
3.7 times faster.
str.translateto improve performance ofimportlib.metadata.Prepared.normalized#143658