Skip to content

Commit 27169dc

Browse files
committed
Move behavior description into the docstring. Remove references to intermediate implementations. Reference the rationale.
1 parent cbadafc commit 27169dc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

importlib_metadata/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,8 @@ def _read_files_egginfo_installed(self):
636636
return
637637

638638
paths = (
639-
py311.relative_fix((subdir / name).resolve())
639+
py311
640+
.relative_fix((subdir / name).resolve())
640641
.relative_to(self.locate_file('').resolve(), walk_up=True)
641642
.as_posix()
642643
for name in text.splitlines()
@@ -928,10 +929,12 @@ def __init__(self, name: str | None):
928929
def normalize(name):
929930
"""
930931
PEP 503 normalization plus dashes as underscores.
932+
933+
Specifically avoids ``re.sub`` as prescribed for performance
934+
benefits (see python/cpython#143658).
931935
"""
932-
# Much faster than re.sub, and even faster than str.translate
933936
value = name.lower().replace("-", "_").replace(".", "_")
934-
# Condense repeats (faster than regex)
937+
# Condense repeats
935938
while "__" in value:
936939
value = value.replace("__", "_")
937940
return value

0 commit comments

Comments
 (0)