Skip to content

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

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from
Open

Alt contains #526

wants to merge 13 commits into from

Conversation

jaypantone
Copy link
Collaborator

No description provided.

@jaypantone jaypantone marked this pull request as ready for review June 24, 2025 02:14
Copy link

@Copilot Copilot AI left a 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))
Copy link
Preview

Copilot AI Jun 24, 2025

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.

Suggested change
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.

Copy link
Member

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.

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