[Python-Dev] Dataclasses and correct hashability

Chris Barker - NOAA Federal chris.barker at noaa.gov
Sun Feb 4 14:59:27 EST 2018


>> IMO, the danger of
>> "@dataclass(hash=True)" far overweighs whatever convenience it might
>> provide.

Is there any reason specifying has=True could set frozen=True unless
the user specifically sets frozen=False?

Or is that already the case?

I think the folks that are concerned about this issue are quite right
— most Python users equate immutable and hashable—so the dataclass API
should reflect that.

And this would still make it easy and clear to specify the unusual
(and arguably dangerous) case of:

hash=True, frozen=False

-CHB

>


More information about the Python-Dev mailing list