<div>2011/3/19 Yaşar Arabacı <span dir="ltr">&lt;<a href="mailto:yasar11732@gmail.com">yasar11732@gmail.com</a>&gt;</span><br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote"><br><br>&gt;&gt;&gt;a=5<br>&gt;&gt;&gt;b=5<br>&gt;&gt;&gt;a == b<br>True<br>&gt;&gt;&gt;a is b<br>True<br>
<br>My question is, why &quot;a is b&quot; is true. What I expected it to be is that, a and b are different things with same value.<br></blockquote></div>
<div>Even stranger:</div>
<div> </div>
<div>&gt;&gt;&gt; a = 10**10<br>&gt;&gt;&gt; b = 10**10<br>&gt;&gt;&gt; a == b<br>True<br>&gt;&gt;&gt; a is b<br>False</div>
<div><br>&gt;&gt;&gt; a = 5<br>&gt;&gt;&gt; b = 5<br>&gt;&gt;&gt; a == b<br>True<br>&gt;&gt;&gt; a is b<br>True<br><br>In the general case, you&#39;re right: a and b point to two different objects, but there is also some kind of optimisation for small numbers, and as a result when a = 5 and b = 5, both point the same &#39;5&#39; object.</div>

<div> </div>
<div>Emmanuel Ruellan<br></div>