<p><span class="h-card" translate="no"><a href="https://mastodon.social/@dabeaz" class="u-url mention">@<span>dabeaz</span></a></span> <span class="h-card" translate="no"><a href="https://ciberlandia.pt/@villares" class="u-url mention">@<span>villares</span></a></span> this has to do with Python&#39;s &quot;interning&quot;, done to preserve memory and efficiency. Rather than store multiple copies of static variables, all variables will point to the same set of values.</p><p>```<br />a = 42<br />b = 42<br />c = float(&#39;nan&#39;)<br />d = float(&#39;nan&#39;)</p><p>assert id(a) == id(b)<br />assert id(c) != id(d)<br />```</p><p>Interning doesn&#39;t happen for nan values because it relies on the fact that the two values are equal.</p>
Reply