title: Is it possible for the Python compiler to optimize away some integer arithmetic?
body: <p>Inspired by <a href="https://stackoverflow.com/questions/11476190/why-0-6-is-6-false">this</a> question about Python caching small integers.</p>
  
  <p>Is it possible for the Python compiler to replace (0 - 6) with -6 at compile time? The code below suggests that it does not. If it is not possible, why not? I don't think that the meaning of <code>0</code>, <code>-</code>, or <code>6</code> can be different at run time.</p>
  
  <p>If this is possible, why does CPython not do it?</p>
  
  <pre><code># test_integers.py
  def test_integers():
      print "-6 is -6 ?", -6 is -6 # True
      print "(0 - 6) is -6 ?", (0 - 6) is -6 # False
  
  # import_test_integers.py
  import test_integers
  test_integers.test_integers()
  </code></pre>
  
  <p>My Python details in case this is very implementation-dependent:</p>
  
  <pre><code>Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) 
  [GCC 4.4.3] on linux2
  </code></pre>