-
Notifications
You must be signed in to change notification settings - Fork 1
Perf/improve performance #19
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
Conversation
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.
Pull Request Overview
This PR aims to improve performance in the bool_parser module by adding caching and streamlining logical operations. Key changes include:
- Introducing the lru_cache decorator on various get_value methods to cache results.
- Replacing iterative for-loops with list comprehensions, built-in any(), and all() for concise logical evaluations.
- Refactoring code in BoolOr and BoolAnd classes to enhance clarity and efficiency.
Comments suppressed due to low confidence (1)
esp_bool_parser/bool_parser.py:70
- Ensure that caching via lru_cache on instance methods is appropriate; since the instance (self) is part of the cache key, any changes to instance state won't invalidate the cache. Verify that instances remain effectively immutable or update the caching strategy accordingly.
@lru_cache
ebaa554 to
9de9a5f
Compare
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.
Pull Request Overview
This PR aims to improve performance by leveraging caching and more concise iterations in boolean evaluation methods.
- Added lru_cache decorators to multiple get_value instance methods to cache computed results.
- Replaced explicit for-loops with Python built-ins (any and all) to improve clarity and performance.
| def __init__(self, t: ParseResults): | ||
| self.attr: str = t[0] | ||
|
|
||
| @lru_cache(None) |
Copilot
AI
May 21, 2025
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.
Using lru_cache on instance methods can lead to unexpected behavior if the instance (self) is mutable or not hashable. Consider ensuring that instances remain immutable or refactoring the caching mechanism to operate on a function that receives only hashable parameters.
No description provided.