We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3c8e1ec + a7aaf72 commit 2c43cfeCopy full SHA for 2c43cfe
1 file changed
importlib_metadata/__init__.py
@@ -8,7 +8,6 @@
8
import zipp
9
import email
10
import types
11
-import inspect
12
import pathlib
13
import operator
14
import textwrap
@@ -1106,6 +1105,9 @@ def _get_toplevel_name(name: PackagePath) -> str:
1106
1105
>>> _get_toplevel_name(PackagePath('foo.dist-info'))
1107
'foo.dist-info'
1108
"""
+ # Defer import of inspect for performance (python/cpython#118761)
1109
+ import inspect
1110
+
1111
return _topmost(name) or (
1112
# python/typeshed#10328
1113
inspect.getmodulename(name) # type: ignore
0 commit comments