Skip to content
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

Earlier initialization of patterns #1103

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding a comment
mmatera committed Sep 28, 2024
commit f409eec784475201f6d2927ea78dc13525af8317
5 changes: 4 additions & 1 deletion mathics/core/pattern.py
Original file line number Diff line number Diff line change
@@ -92,7 +92,9 @@ class BasePattern(ABC):

expr: BaseElement

# this attribute allows for a faster match algorithm based on sameq
# this attribute allows for a faster match algorithm based on sameq.
Copy link
Member

Choose a reason for hiding this comment

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

Do you mean sameQ ?

# Probably we should split ExpressionPattern into two different classes,
# one for literal patterns and the other for "Regular" ExpressionPatterns.
isliteral: bool = False

# TODO: In WMA, when a BasePattern is created, the attributes
@@ -459,6 +461,7 @@ def match(
"""Try to match the pattern against an Expression"""
evaluation.check_stopped()
if self.isliteral:
print(self.expr, "is literal")
if expression.sameQ(self.expr):
# yield vars, None
yield_func(vars_dict, None)