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

Add eq=False to node classes #1500

Merged
merged 1 commit into from
Nov 9, 2024
Merged

Add eq=False to node classes #1500

merged 1 commit into from
Nov 9, 2024

Conversation

plypaul
Copy link
Contributor

@plypaul plypaul commented Nov 4, 2024

This sets eq=False for node dataclasses as nodes should be unique, and equivalence methods should be used for checking as the nodes represent recursive data structures. Without this, comparisons or using nodes as keys can be slow as the generated equals function will traverse the recursive structure.

@cla-bot cla-bot bot added the cla:yes label Nov 4, 2024
@plypaul plypaul marked this pull request as ready for review November 4, 2024 17:06
@@ -57,7 +57,7 @@ def visit_node(self, node: DagNode) -> VisitorOutputT: # noqa: D102
DagNodeT = TypeVar("DagNodeT", bound="DagNode")


@dataclass(frozen=True)
@dataclass(frozen=True, eq=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a comment here explaining essentially what you explained in the PR description? Will likely be helpful to future devs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

This sets `eq=False` for node dataclasses as nodes should be unique, and
equivalence methods should be used for checking as the nodes represent
recursive data structures. Without this, comparisons or using nodes as keys
can be slow as the generated equals function will traverse the recursive
structure.
@plypaul plypaul merged commit de6ed9d into main Nov 9, 2024
15 checks passed
@plypaul plypaul deleted the p--cte--05 branch November 9, 2024 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants