-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: cache parsed requirements #828
perf: cache parsed requirements #828
Conversation
Reviewer's Guide by SourceryThis pull request introduces caching for parsed requirements using the Sequence diagram for cached requirement parsingsequenceDiagram
participant Client
participant Parser
participant Cache
Note over Parser: New caching mechanism
Client->>Parser: parse_requirement(requirement_string)
alt Cache hit
Parser->>Cache: Check cache
Cache-->>Parser: Return cached Requirement
Parser-->>Client: Return cached Requirement
else Cache miss
Parser->>Cache: Check cache
Cache-->>Parser: Not found
Parser->>Parser: Create new Requirement
Parser->>Cache: Store in cache
Parser-->>Client: Return new Requirement
end
Class diagram for requirement parsing changesclassDiagram
class Requirement {
+str name
+str url
+Sequence[str] extras
+str constraint
+__init__(requirement_string: str)
+__str__()
+__repr__()
}
class RequirementParser {
+@cache parse_requirement(requirement_string: str)
}
RequirementParser ..> Requirement : creates
note for RequirementParser "New cached parser function"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @radoering - I've reviewed your changes and they look great!
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Caching the requirements should be safe because we use them read-only.
Testing with the
pyproject.toml
from python-poetry/poetry#9956 (comment):Summary by Sourcery
Cache parsed requirement strings to improve performance, especially when regenerating lock files.
Enhancements:
functools.cache
.Tests: