Skip to content

Commit eb7c1eb

Browse files
committed
Calculate candidate string versions only once in get_applicable_candidates
1 parent 9ef0fdf commit eb7c1eb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/pip/_internal/index/package_finder.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ def get_applicable_candidates(
452452
# Using None infers from the specifier instead.
453453
allow_prereleases = self._allow_all_prereleases or None
454454
specifier = self._specifier
455+
candidates_and_versions = [(c, str(c.version)) for c in candidates]
455456
versions = {
456457
str(v)
457458
for v in specifier.filter(
@@ -462,13 +463,13 @@ def get_applicable_candidates(
462463
# types. This way we'll use a str as a common data interchange
463464
# format. If we stop using the pkg_resources provided specifier
464465
# and start using our own, we can drop the cast to str().
465-
(str(c.version) for c in candidates),
466+
(v for _, v in candidates_and_versions),
466467
prereleases=allow_prereleases,
467468
)
468469
}
469470

470471
# Again, converting version to str to deal with debundling.
471-
applicable_candidates = [c for c in candidates if str(c.version) in versions]
472+
applicable_candidates = [c for c, v in candidates_and_versions if v in versions]
472473

473474
filtered_applicable_candidates = filter_unallowed_hashes(
474475
candidates=applicable_candidates,

0 commit comments

Comments
 (0)