Skip to content

Call __eq__ from __ne__ for user defined __eq__#593

Merged
jcrist merged 1 commit intomainfrom
struct-override-eq
Nov 25, 2023
Merged

Call __eq__ from __ne__ for user defined __eq__#593
jcrist merged 1 commit intomainfrom
struct-override-eq

Conversation

@jcrist
Copy link
Copy Markdown
Owner

@jcrist jcrist commented Nov 25, 2023

If a user manually defines an __eq__ for a Struct class, the default __ne__ implementation will now call the user-defined __eq__ and invert the result, rather than applying the standard __ne__ logic. This makes it easier for users to manually override __eq__, and matches the behavior of standard python classes.

Fixes #585.

If a user manually defines an `__eq__` for a `Struct` class, the default
`__ne__` implementation will now call the user-defined `__eq__` and
invert the result, rather than applying the standard `__ne__` logic.
This makes it easier for users to manually override `__eq__`, and
matches the behavior of standard python classes.
@jcrist jcrist merged commit 36b6aa8 into main Nov 25, 2023
@jcrist jcrist deleted the struct-override-eq branch November 25, 2023 03:31
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.

__ne__ does not defer to custom __eq__

1 participant