Skip to content

Commit 14736ea

Browse files
DefaultRyansbidoul
authored andcommitted
Document _normalize_path_cached
1 parent 6a8e403 commit 14736ea

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/pip/_internal/req/req_uninstall.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ def __init__(self, dist: BaseDistribution) -> None:
313313
self._pth: Dict[str, UninstallPthEntries] = {}
314314
self._dist = dist
315315
self._moved_paths = StashedUninstallPathSet()
316+
# Create local cache of normalize_path results. Creating an UninstallPathSet
317+
# can result in hundreds/thousands of redundant calls to normalize_path with the same
318+
# args, which hurts performance.
316319
self._normalize_path_cached = functools.lru_cache(maxsize=256)(normalize_path)
317320

318321
def _permitted(self, path: str) -> bool:

0 commit comments

Comments
 (0)