Skip to content

Commit

Permalink
Merge pull request #12080 from mauritsvanrees/maurits-issue-12079-slo…
Browse files Browse the repository at this point in the history
…w-importlib
  • Loading branch information
uranusjr authored Jun 16, 2023
2 parents 8a1eea4 + 6aef932 commit 5190ef7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/12079.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix slowness when using ``importlib.metadata`` (the default way for pip to read metadata in Python 3.11+) and there is a large overlap between already installed and to-be-installed packages.
5 changes: 4 additions & 1 deletion src/pip/_internal/resolution/resolvelib/candidates.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def __init__(
self.dist = dist
self._ireq = _make_install_req_from_dist(dist, template)
self._factory = factory
self._version = None

# This is just logging some messages, so we can do it eagerly.
# The returned dist would be exactly the same as self.dist because we
Expand Down Expand Up @@ -376,7 +377,9 @@ def name(self) -> str:

@property
def version(self) -> CandidateVersion:
return self.dist.version
if self._version is None:
self._version = self.dist.version
return self._version

@property
def is_editable(self) -> bool:
Expand Down

0 comments on commit 5190ef7

Please sign in to comment.