GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — importlib.metadata: Use `str.translate` to improve performance of `importlib.metadata.Prepared.normalized` · Issue #143658 · python/cpython

importlib.metadata: Use str.translate to improve performance of importlib.metadata.Prepared.normalized #143658

New issue
Copy link
New issue
Copy link
Closed
Closed
importlib.metadata: Use str.translate to improve performance of importlib.metadata.Prepared.normalized#143658
Copy link
Labels
performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-featureA feature request or enhancementA feature request or enhancement

Description

@hugovk
hugovk
opened on Jan 10, 2026
Issue body actions

Feature or enhancement

Proposal:

We can apply @henryiii's improvement to packaging in pypa/packaging#1030 (see also https://iscinumpy.dev/post/packaging-faster/) to improve the performance of canonicalize_name and make it ~3.7 times faster.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-143658: importlib.metadata: Use str.translate to improve performance of importlib.metadata.Prepared.normalized #143660
  • gh-143658: Use str.lower and replace to further improve performance of importlib.metadata.Prepared.normalized #144083

Activity

  1. hugovk
    added
    type-featureA feature request or enhancementA feature request or enhancement
    performancePerformance or resource usagePerformance or resource usage
    topic-importlib
    on Jan 10, 2026
  2. picnixz
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Jan 10, 2026
  3. picnixz
    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
  4. picnixz
    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
  5. hugovk
    added a commit that references this issue on Jan 13, 2026

    gh-143658: importlib.metadata: Use `str.translate` to improve perform…

    cbf9b8c
  6. hugovk
    closed this as completedon Jan 13, 2026
  7. hugovk
    added a commit that references this issue on Feb 6, 2026

    gh-143658: Use `str.lower` and `replace` to further improve performan…

    28fb13c
  8. thunder-coding
    added 2 commits that reference this issue on Feb 15, 2026

    pythongh-143658: importlib.metadata: Use `str.translate` to improve p…

    ba90f74

    pythongh-143658: Use `str.lower` and `replace` to further improve per…

    9ecbd9f
  9. jaraco commented on Mar 20, 2026

    @jaraco
    jaraco
    on Mar 20, 2026
    Member
    More actions

    We can apply @henryiii's improvement to packaging in pypa/packaging#1030 (see also https://iscinumpy.dev/post/packaging-faster/) to improve the performance of canonicalize_name and make it ~3.7 times faster.

    Let it be stated that the referenced blog provides the rationale why this change is valuable.

  10. jaraco commented on Mar 20, 2026

    @jaraco
    jaraco
    on Mar 20, 2026
    Member
    More actions

    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?

  11. ljfp
    added a commit that references this issue on Apr 25, 2026

    pythongh-143658: Use `str.lower` and `replace` to further improve per…

    9e04a8f
  12. jaraco
    added a commit that references this issue on Oct 31, 2026

    gh-160386: Apply changes from importlib_metadata 9.1 (#160387)

    5a97efe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance or resource usagePerformance or resource usagestdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-importlibtype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.