Skip to content

perf: create link objects lazily#10951

Open
radoering wants to merge 1 commit into
python-poetry:mainfrom
radoering:perf-link-cache-2
Open

perf: create link objects lazily#10951
radoering wants to merge 1 commit into
python-poetry:mainfrom
radoering:perf-link-cache-2

Conversation

@radoering

Copy link
Copy Markdown
Member

Another small performance improvement, which makes locking about 10 % faster in some cases.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • With LinkCache now holding factories instead of Link instances, repeated iteration over links/links_for_version will rebuild Link objects each time; if these APIs are used frequently in hot paths, consider memoizing the constructed Links per factory or documenting that callers should cache results if they rely on reuse.
  • In HTMLPage._link_cache, the comment notes that links are built eagerly due to lack of a separate filename field; if this becomes a noticeable hotspot, you might consider a lightweight helper that extracts the filename from the URL without constructing a full Link, to align with the lazy strategy introduced for the JSON source.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- With `LinkCache` now holding factories instead of `Link` instances, repeated iteration over `links`/`links_for_version` will rebuild `Link` objects each time; if these APIs are used frequently in hot paths, consider memoizing the constructed `Link`s per factory or documenting that callers should cache results if they rely on reuse.
- In `HTMLPage._link_cache`, the comment notes that links are built eagerly due to lack of a separate filename field; if this becomes a noticeable hotspot, you might consider a lightweight helper that extracts the filename from the URL without constructing a full `Link`, to align with the lazy strategy introduced for the JSON source.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants