You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
importlib.metadata: Use str.translate to improve performance of importlib.metadata.Prepared.normalized #143658
changed the title [-]importlib.metadata: Use `translate` to improve performance of `canonicalize_name`[/-][+]importlib.metadata: Use `translate` to improve performance of `importlib.metadata.Prepared.normalized`[/+]on Jan 10, 2026
changed the title [-]importlib.metadata: Use `translate` to improve performance of `importlib.metadata.Prepared.normalized`[/-][+]importlib.metadata: Use `str.translate` to improve performance of `importlib.metadata.Prepared.normalized`[/+]on Jan 10, 2026
In python/importlib_metadata#533 (comment), I measured the performance benefit and find that it saves ~300 ns per call (on an M3 Mac pro). It's going to take a lot of calls to recoup the value from this change, and most users are never going to notice the benefit. Is there any known use case where we know users will benefit meaningfully from this change?
Activity
[-]importlib.metadata: Use `translate` to improve performance of `canonicalize_name`[/-][+]importlib.metadata: Use `translate` to improve performance of `importlib.metadata.Prepared.normalized`[/+][-]importlib.metadata: Use `translate` to improve performance of `importlib.metadata.Prepared.normalized`[/-][+]importlib.metadata: Use `str.translate` to improve performance of `importlib.metadata.Prepared.normalized`[/+]gh-143658: importlib.metadata: Use `str.translate` to improve perform…
gh-143658: Use `str.lower` and `replace` to further improve performan…
pythongh-143658: importlib.metadata: Use `str.translate` to improve p…
pythongh-143658: Use `str.lower` and `replace` to further improve per…
jaraco commentedon Mar 20, 2026
Let it be stated that the referenced blog provides the rationale why this change is valuable.
jaraco commentedon Mar 20, 2026
In python/importlib_metadata#533 (comment), I measured the performance benefit and find that it saves ~300 ns per call (on an M3 Mac pro). It's going to take a lot of calls to recoup the value from this change, and most users are never going to notice the benefit. Is there any known use case where we know users will benefit meaningfully from this change?
pythongh-143658: Use `str.lower` and `replace` to further improve per…