-
Notifications
You must be signed in to change notification settings - Fork 4
Alt contains #526
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
base: develop
Are you sure you want to change the base?
Alt contains #526
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 refactors the GriddedPerm containment logic to improve performance by caching values and reordering checks. Key changes include:
- Caching the length of the pattern in init and using it in len.
- Refactoring contains to delegate to a new contains_patt method.
- Introducing contains_patt_proper and contains_pos methods for optimized checks.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
tilings/griddedperm.py | Optimized containment logic with caching and refactored methods. |
CHANGELOG.md | Updated changelog to reflect new performance improvements. |
# positions of self could potentially contain the positions of patt, | ||
# and only if so does it check if there is an occurrence of patt in | ||
# self. We also cached GriddedPerm.len at this time. | ||
return self.contains_pos(patt) and any(True for _ in patt.occurrences_in(self)) |
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.
[nitpick] The generator expression 'any(True for _ in ...)' is redundant; consider using 'any(patt.occurrences_in(self))' directly for clarity and efficiency.
return self.contains_pos(patt) and any(True for _ in patt.occurrences_in(self)) | |
return self.contains_pos(patt) and any(patt.occurrences_in(self)) |
Copilot uses AI. Check for mistakes.
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.
This doesn't work as some of the objects yielded have a False boolean.
No description provided.