<div class="gmail_quote">On Sun, Jan 15, 2012 at 6:30 AM, Stefan Behnel <span dir="ltr">&lt;<a href="mailto:stefan_ml@behnel.de">stefan_ml@behnel.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Terry Reedy, 14.01.2012 06:43:<br>
<div class="im">&gt; On 1/13/2012 8:58 PM, Gregory P. Smith wrote:<br>
&gt;<br>
&gt;&gt; It is perfectly okay to break existing users who had anything depending<br>
&gt;&gt; on ordering of internal hash tables. Their code was already broken.<br>
&gt;<br>
&gt; Given that the doc says &quot;Return the hash value of the object&quot;, I do not<br>
&gt; think we should be so hard-nosed. The above clearly implies that there is<br>
&gt; such a thing as *the* Python hash value for an object. And indeed, that has<br>
&gt; been true across many versions. If we had written &quot;Return a hash value for<br>
&gt; the object, which can vary from run to run&quot;, the case would be different.<br>
<br>
</div>Just a side note, but I don&#39;t think hash() is the right place to document<br>
this. </blockquote><div><br>You mean we shouldn&#39;t document that the hash() of a string will vary per run?<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

Hashing is a protocol in Python, just like indexing or iteration.<br>
Nothing keeps an object from changing its hash value due to modification,<br>
</blockquote><div><br>Eh? There&#39;s a huge body of cultural awareness that only immutable objects should define a hash, implying that the hash remains constant during the object&#39;s lifetime.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

and that would even be valid in the face of the usual dict lookup<br>
invariants if changes are only applied while the object is not referenced<br>
by any dict.</blockquote><div><br>And how would you know it isn&#39;t?<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> So the guarantees do not depend on the function hash() and may<br>


be even weaker than your above statement.<span class="HOEnZb"></span><br></blockquote></div><br>There are no actual guarantees for hash(), but lots of rules for well-behaved hashes.<br clear="all"><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)<br>