File tree 1 file changed +4
-8
lines changed
1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -1070,9 +1070,6 @@ def _topmost(name: PackagePath) -> Optional[str]:
1070
1070
return top if rest else None
1071
1071
1072
1072
1073
- inspect = None
1074
-
1075
-
1076
1073
def _get_toplevel_name (name : PackagePath ) -> str :
1077
1074
"""
1078
1075
Infer a possibly importable module name from a name presumed on
@@ -1091,13 +1088,12 @@ def _get_toplevel_name(name: PackagePath) -> str:
1091
1088
>>> _get_toplevel_name(PackagePath('foo.dist-info'))
1092
1089
'foo.dist-info'
1093
1090
"""
1094
- n = _topmost (name )
1095
- if n :
1091
+ if n := _topmost (name ):
1096
1092
return n
1097
1093
1098
- global inspect
1099
- if inspect is None :
1100
- import inspect
1094
+ # We're deffering import of inspect to speed up overall import time
1095
+ import inspect
1096
+
1101
1097
return inspect .getmodulename (name ) or str (name )
1102
1098
1103
1099
You can’t perform that action at this time.
0 commit comments