Closed
Description
Context: https://github.com/pypa/pip/pull/8014/files#r407079100
I think it would be best to implement something like:
@dataclasses.dataclass()
class CandidateSequence(collections.abc.Sequence):
before: Sequence[Candidate]
found_iter: Iterator[Candidate]
after: Sequence[Candidate]
# Implement the sequence protocol and __reverse__()
# https://docs.python.org/3.8/reference/datamodel.html#object.__reversed__
class Factory:
def find_matches(self):
def found_iter():
found = self._factory.finder.find_best_candidate(...)
for ican in found.iter_applicable():
yield self._make_candidate_from_link(...)
dist = self._installed_dists.get(name)
if dist is not None:
after = [dist]
else:
after = []
return CandidateSequence(before=[], found_iter=found_iter(), after=after)
We would be able to skip network I/O if the installed version is good enough.
Metadata
Metadata
Assignees
Labels
No labels