Skip to content

Commit

Permalink
Remove stray id(candidate) call
Browse files Browse the repository at this point in the history
Also moves the incompatibility candidate calculation to closer to their
usages.
  • Loading branch information
uranusjr committed Apr 23, 2021
1 parent 9cab983 commit cf4e3aa
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,17 +341,12 @@ def find_candidates(
constraint: Constraint,
prefers_installed: bool,
) -> Iterable[Candidate]:

# Since we cache all the candidates, incompatibility identification
# can be made quicker by comparing only the id() values.
incompat_ids = {id(c) for c in incompatibilities.get(identifier, ())}

# Collect basic lookup information from the requirements.
explicit_candidates = set() # type: Set[Candidate]
ireqs = [] # type: List[InstallRequirement]
for req in requirements[identifier]:
cand, ireq = req.get_candidate_lookup()
if cand is not None and id(cand):
if cand is not None:
explicit_candidates.add(cand)
if ireq is not None:
ireqs.append(ireq)
Expand Down Expand Up @@ -385,6 +380,10 @@ def find_candidates(
# target architecture, no candidates will ever be valid.
return ()

# Since we cache all the candidates, incompatibility identification
# can be made quicker by comparing only the id() values.
incompat_ids = {id(c) for c in incompatibilities.get(identifier, ())}

# If none of the requirements want an explicit candidate, we can ask
# the finder for candidates.
if not explicit_candidates:
Expand Down

0 comments on commit cf4e3aa

Please sign in to comment.