Skip to content

Commit

Permalink
Optimize upgrade of already-satisfied pinned requirement
Browse files Browse the repository at this point in the history
Example: after installing six 1.12.0, `pip install -Uv six==1.12.0`
now returns immediately, instead of going to the index to check for a
version that can’t possibly be considered better.

This optimization is most significant when upgrading via a
requirements file with many pinned versions and some non-pinned
versions.

Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Oct 5, 2019
1 parent e6f69fa commit d4191c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/7132.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Skip reaching out to the package index, if a pinned version is already satisfied.
4 changes: 4 additions & 0 deletions src/pip/_internal/legacy_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ def _check_skip_installed(self, req_to_install):
# requirements we have to pull the tree down and inspect to assess
# the version #, so it's handled way down.
if not req_to_install.link:
if req_to_install.is_pinned:
# No need to check the index for a better version.
return 'pinned at installed version'

try:
self.finder.find_requirement(req_to_install, upgrade=True)
except BestVersionAlreadyInstalled:
Expand Down

0 comments on commit d4191c3

Please sign in to comment.