<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Feb 4, 2018 at 7:54 PM, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="m_7510274023528486560gmail-">On 5 February 2018 at 08:31, Guido van Rossum <<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>> wrote:<br>
> On Sun, Feb 4, 2018 at 11:59 AM, Chris Barker - NOAA Federal<br>
> <<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>> wrote:<br>
>><br>
>> I think the folks that are concerned about this issue are quite right<br>
>> — most Python users equate immutable and hashable—so the dataclass API<br>
>> should reflect that.<br>
><br>
> Since they are *not* equivalent (consider a tuple containing a list) I'm not<br>
> at all convinced that any API in the core language should "reflect" this<br>
> misconception, depending on how you meant that.<br>
<br>
</span>Lists are themselves mutable, and hence inherently unhashable.<br>
<br>
Tuples are themselves immutable, and hence hashable if their contents are.<br>
<br>
I interpret Chris's comment as saying that data classes should behave<br>
the same way that the builtin container types do:<br></blockquote><div><br></div><div>pretty much, yes,</div><div><br></div><div>But a bit more detail -- I'm commenting on the API, not the capability - that is, since users often equate hashable and immutability, they will expect that if they say hash=True, then will get an immutable, and if they say frozen=True, they will get something hashable (as long as the fields are hashable, just like a tuple.</div><div><br></div><div>That is, even though these concepts are independent, the defaults shouldn't reflect that.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
It's the ability to ask the interpreter to guess what you mean<br>
"frozen=False, hash=True" that creates the likelihood of confusion.<br></blockquote><div><br></div><div>Actually, I think if the user does explicitly specify: "frozen=False, hash=True", then that's what they should get, and it's a pretty fragile beast, but apparently there's enough of a use case for folks to want it, and I don't think it's a confusing API.</div><div><br></div><div>-CHB</div><div> </div></div>-- <br><div class="m_7510274023528486560gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            <a href="tel:(206)%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a>   voice<br>7600 Sand Point Way NE   <a href="tel:(206)%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a>   fax<br>Seattle, WA  98115       <a href="tel:(206)%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a>   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div></div>