perf: cache link objects that have been created lazily#10953
Open
radoering wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/poetry/repositories/link_sources/base.py" line_range="175-180" />
<code_context>
return True
@cached_property
- def _link_cache(self) -> LinkCache:
- raise NotImplementedError()
+ def _link_factory_cache(self) -> LinkFactoryCache:
+ """ATTENTION:
+ The factories should only be called in links_for_version
+ so that the __link_cache, which avoids to call the same factory twice,
+ is populated.
+ """
</code_context>
<issue_to_address>
**nitpick (typo):** Polish the wording in the `_link_factory_cache` docstring for clarity.
The phrase "avoids to call the same factory twice" is awkward. Please rephrase to something like "avoids calling the same factory twice" for smoother wording.
```suggestion
def _link_factory_cache(self) -> LinkFactoryCache:
"""ATTENTION:
The factories should only be called in links_for_version
so that the __link_cache, which avoids calling the same factory twice,
is populated.
"""
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
python-poetry#10951 prevented the creation of unnecessary link objects. However, this also resulted in link objects that were requested multiple times being created multiple times. Depending on a project's dependencies the first or the latter is more relevant. Thus, a two-stage cache makes sense to get the best of both.
5fb0de0 to
a341710
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#10951 prevented the creation of unnecessary link objects. However, this also resulted in link objects that were requested multiple times being created multiple times. Depending on a project's dependencies the first or the latter is more relevant. Thus, a two-stage cache makes sense to get the best of both.