On 11/27/2017 10:51 AM, Guido van Rossum wrote: > Following up on this subthread (inline below). > Didn't we at one point have something like > > isinstance(other, self.__class__) and fields(other) == fields(self) and > <all individual fields match> > > (plus some optimization if the types are identical)? > > That feels ideal, because it means you can subclass Point just to add > some methods and it will stay comparable, but if you add fields it will > always be unequal. One thing this doesn't let you do is compare instances of two different subclasses of a base type: @dataclass class B: i: int @dataclass class C1(B): pass @dataclass class C2(B): pass You can't compare C1(0) and C2(0), because neither one is an instance of the other's type. The test to get this case to work would be expensive: find the common ancestor, and then make sure no fields have been added since then. And I haven't thought through multiple inheritance. I suggest we don't try to support this case. Eric.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4