On Thursday, February 1, 2018 8:37:41 PM EST Eric V. Smith wrote:
> > hash=None and compare=True leads to the same result, which, I
> > think is even worse.
> 
> Have you actually tried that?

I meant this:

@dataclasses.dataclass(hash=True)
class A:
    foo: int = dataclasses.field(compare=True)

> I don't recommend ever specifying the decorator hash= parameter
> unless you have an unusual use case, in which case it's on you to
> get it right. 

In my experience this type of breakage is so subtle that people will 
happily write code lots of code like this without noticing.  My main 
objection here is that the dataclass does not go far enough to prevent 
obviously wrong behaviour.  Or it goes too far with the whole hash/
frozen distinction.

                             Elvis


_______________________________________________
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

Reply via email to