ericvsmith / dataclasses

Apache License 2.0
587 stars 53 forks source link

Remove per-field "hash" flag #44

Closed ericvsmith closed 7 years ago

ericvsmith commented 7 years ago

Since we're saying it should always match what's currently the "cmp" flag, let's just force it to be the same by getting rid of the "hash" flag. This will slightly simplify the field() call.

gvanrossum commented 7 years ago

Hm, but excluding a field from the hash that's included in eq still could be useful, e.g. if the field's hash would be expensive to compute and there are other fields contributing to the overall hash. (Not the other way around, but you've already got that covered.)

ericvsmith commented 7 years ago

Okay, I'll leave the field-level hash and cmp flags.

ericvsmith commented 7 years ago

Although, if you can leave it out of the hash, why can't you also leave it out of the comparison functions?

I'm just trying to make the interface simpler, but if both flags need to stay, so be it.

gvanrossum commented 7 years ago

There's a legitimate reason for having a field in the eq but not in the hash. After all hash is always followed by an eq check and it is totally legit for the eq check to say two objects are not equal even though their hashes are equal.

ericvsmith commented 7 years ago

Okay. I'll leave it it (this time for keeps!).