[Python-Dev] Dataclasses and correct hashability

Eric V. Smith eric at trueblade.com
Fri Feb 2 11:09:26 EST 2018


On 2/2/2018 10:56 AM, Elvis Pranskevichus wrote:
> On Friday, February 2, 2018 10:51:11 AM EST Eric V. Smith wrote:
>> I was specifically talking about the case of a non-frozen, hashable
>> class. If you want to make a class frozen and hashable, then:
>>
>> @dataclass(frozen=True)
>>
>> will do just that.
>>
>> The case you brought up initially is the non-frozen, hashable class.
>> It's that case that I think is very rare. I'll ask again: what's your
>> use case for wanting a non-frozen, hashable class? I'm genuinely
>> interested.
> 
> My point is exactly that there is _no_ valid use case, so (hash=True,
> frozen=False) should not be a thing!  Why are you so insistent on adding
> a dangerous option which you admit is nearly useless?

Because it's not the default, it will be documented as being an advanced 
use case, and it's useful in rare instances.

And as I've said a number of times, both here and in other discussions, 
I'm not arguing strenuously for this. I just think that, given that it's 
not the default and it's not recommended and is useful in advanced 
cases, I would prefer to leave it in. I understand that you disagree 
with me.

Eric


More information about the Python-Dev mailing list