title: Why does Python handle '1 is 1**2' differently from '1000 is 10**3'?
body: <p>Inspired by <a href="https://stackoverflow.com/questions/11485879/is-it-possible-for-the-python-compiler-to-optimize-away-some-integer-arithmetic">this</a> question about caching small integers and strings I discovered the following behavior which I don't understand.</p>
  
  <pre><code>&gt;&gt;&gt; 1000 is 10**3
  False
  </code></pre>
  
  <p>I thought I understood this behavior: 1000 is to big to be cached. 1000 and 10**3 point to 2 different objects. But I had it wrong:</p>
  
  <pre><code>&gt;&gt;&gt; 1000 is 1000
  True
  </code></pre>
  
  <p>So, maybe Python treats calculations differently from 'normal' integers. But that assumption is also not correct:</p>
  
  <pre><code>&gt;&gt;&gt; 1 is 1**2
  True
  </code></pre>
  
  <p>How can this behavior be explained?</p>