That's much less self-descriptive and harder to search Google or StackOverflow for. It's also easier to overlook. We really want to send the signal that this is unsafe and requires serious consideration before it is turned on.
On Tue, Feb 6, 2018 at 11:57 AM, David Mertz <me...@gnosis.cx> wrote: > Honestly, the name I would most want for the keyword argument is '_hash'. > That carries the semantics I desire. > > On Feb 6, 2018 10:13 AM, "Ethan Furman" <et...@stoneleaf.us> wrote: > >> On 02/06/2018 09:38 AM, Guido van Rossum wrote: >> >> Where do you get the impression that one would have to explicitly request >>> __hash__ if frozen=True is set? To the >>> contrary, my proposal is for @dataclass to automatically add a __hash__ >>> method when frozen=True is set. This is what the >>> code currently released as 3.7.0b1 does if hash=None (the default). >>> >> >> Which is my issue with the naming -- although, really, it's more with the >> parameter/argument: in a hand-written class, >> >> __hash__ = None >> >> means the object in is not hashable, but with the decorator: >> >> @dataclass(..., hash=None, ...) >> >> it means something else. >> >> My preference for "fixing" the issue: >> >> 1) make the default be a custom object (not None), so that `hash=None` >> means disable hashing >> >> 2) change the param name -- maybe to `add_hash` (I agree with D'Aprano >> that `unsafe_hash` can be misleading) >> >> -- >> ~Ethan~ >> _______________________________________________ >> Python-Dev mailing list >> Python-Dev@python.org >> https://mail.python.org/mailman/listinfo/python-dev >> Unsubscribe: https://mail.python.org/mailman/options/python-dev/mertz%40g >> nosis.cx >> > > _______________________________________________ > Python-Dev mailing list > Python-Dev@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)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com