jcrist / msgspec

A fast serialization and validation library, with builtin support for JSON, MessagePack, YAML, and TOML
https://jcristharif.com/msgspec/
BSD 3-Clause "New" or "Revised" License
2.3k stars 67 forks source link

Call `__eq__` from `__ne__` for user defined `__eq__` #593

Closed jcrist closed 10 months ago

jcrist commented 10 months ago

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.