Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: python/importlib_metadata
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.3.0
Choose a base ref
...
head repository: python/importlib_metadata
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v8.4.0
Choose a head ref
  • 8 commits
  • 2 files changed
  • 2 contributors

Commits on Aug 5, 2024

  1. Defer import inspect

    danielhollas committed Aug 5, 2024
    Copy the full SHA
    8e66fbc View commit details

Commits on Aug 20, 2024

  1. Don't use global var

    - wallrusify
    - add a note about deffered import
    danielhollas committed Aug 20, 2024
    Copy the full SHA
    debb516 View commit details
  2. Copy the full SHA
    e99c105 View commit details
  3. Use third-person imperative voice and link to issue in comment.

    jaraco committed Aug 20, 2024
    Copy the full SHA
    a7aaf72 View commit details
  4. Merge pull request #499 from danielhollas/defer-inspect

    Speed up import time by deferring inspect
    jaraco authored Aug 20, 2024
    Copy the full SHA
    2c43cfe View commit details
  5. Remove workaround for python/typeshed#10328.

    jaraco committed Aug 20, 2024
    Copy the full SHA
    ebcdcfd View commit details
  6. Add news fragment.

    jaraco committed Aug 20, 2024
    Copy the full SHA
    71b4678 View commit details
  7. Finalize

    jaraco committed Aug 20, 2024
    Copy the full SHA
    1616cb3 View commit details
Showing with 13 additions and 6 deletions.
  1. +9 −0 NEWS.rst
  2. +4 −6 importlib_metadata/__init__.py
9 changes: 9 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v8.4.0
======

Features
--------

- Deferred import of inspect for import performance. (#499)


v8.3.0
======

10 changes: 4 additions & 6 deletions importlib_metadata/__init__.py
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
import zipp
import email
import types
import inspect
import pathlib
import operator
import textwrap
@@ -1106,11 +1105,10 @@ def _get_toplevel_name(name: PackagePath) -> str:
>>> _get_toplevel_name(PackagePath('foo.dist-info'))
'foo.dist-info'
"""
return _topmost(name) or (
# python/typeshed#10328
inspect.getmodulename(name) # type: ignore
or str(name)
)
# Defer import of inspect for performance (python/cpython#118761)
import inspect

return _topmost(name) or (inspect.getmodulename(name) or str(name))


def _top_level_inferred(dist):