I'm not a fan, sorry. On Tue, Feb 6, 2018 at 7:33 PM, Ethan Furman <ethan at stoneleaf.us> wrote: > On 02/06/2018 06:48 PM, Guido van Rossum wrote: > > That seems a rare case (though I hadn't thought of it). I had thought of >> the use case where you want a frozen type >> without a hash; that you can presumably implement using >> >> def __hash__(self): raise TypeError("not hashable") >> >> We can do a similar thing to preserve the superclass __hash__ if it's >> rare enough: >> >> def __hash__(self): return super().__hash__() >> >> If at all possible I'd like to kill the tri-state hash= flag -- the >> amount of time spent creating and discussing the >> huge table in the bpo issue are an indication of how much effort it would >> take other people to understand it. >> > > I think the biggest reason this has become so complicated is because we > are refusing to use an Enum: > > class Hashable(Enum): > IF_SAFE = 1 > ADD = 2 > DEFER = 3 > NONE = 4 > > IF_SAFE is currently the False value. > ADD is currently the True value > DEFER means don't add one > NONE means set __hash__ to None > > The only thing missing now is a setting to indicate that dataclass should > do nothing if the class already has a __hash__ method -- possibly DEFER, > although I think IF_SAFE can include "the class already has one, it's not > safe to override it". > > If either of those use cases becomes annoyingly common we'll have to think >> of something else. >> > > Or we could solve it now and not have to deal with backwards-compatibility > issues in the future. > > -- > ~Ethan~ > _______________________________________________ > Python-Dev mailing list > Python-Dev at python.org > https://mail.python.org/mailman/listinfo/python-dev > Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido% > 40python.org > -- --Guido van Rossum (python.org/~guido) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180206/7986ff2b/attachment.html>
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