Skip to content

Commit 0aee48f

Browse files
authored
Merge pull request pypa#9265 from uranusjr/new-resolver-cache-installed-candidates
Cache AlreadyInstalledCandidate
2 parents 27d8687 + 120105d commit 0aee48f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

news/9117.bugfix.rst

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
New resolver: The "Requirement already satisfied" log is not printed only once
2+
for each package during resolution.

src/pip/_internal/resolution/resolvelib/factory.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ def __init__(
9696

9797
self._link_candidate_cache = {} # type: Cache[LinkCandidate]
9898
self._editable_candidate_cache = {} # type: Cache[EditableCandidate]
99+
self._installed_candidate_cache = {
100+
} # type: Dict[str, AlreadyInstalledCandidate]
99101

100102
if not ignore_installed:
101103
self._installed_dists = {
@@ -117,7 +119,11 @@ def _make_candidate_from_dist(
117119
template, # type: InstallRequirement
118120
):
119121
# type: (...) -> Candidate
120-
base = AlreadyInstalledCandidate(dist, template, factory=self)
122+
try:
123+
base = self._installed_candidate_cache[dist.key]
124+
except KeyError:
125+
base = AlreadyInstalledCandidate(dist, template, factory=self)
126+
self._installed_candidate_cache[dist.key] = base
121127
if extras:
122128
return ExtrasCandidate(base, extras)
123129
return base

0 commit comments

Comments
 (0)