title: How to cache values in script mode?
body: <p>My code is:</p>
  <pre><code>x = 1000
  y = x + 0
  z = 1000
  
  print(x is y, x is z, y is z)
  </code></pre>
  <p>In REPL mode I have next result:</p>
  <pre><code>&gt;&gt;&gt; False False False
  </code></pre>
  <p>But if I run script in script mode (like '1.py' for example) I have next result.</p>
  <pre><code>&gt;&gt;&gt; False True False
  </code></pre>
  <p>Similar result in REPL with</p>
  <pre><code>&gt;&gt;&gt; x = 1000; y = x + 0; z = 1000
  &gt;&gt;&gt; print(x is y, x is z, y is z)
  False True False
  </code></pre>
  <p>I think that lexical analyzer make object optimization by translate my code to bite code. But I can't find desciption this process in documentation or books.</p>
  <p>Where can I learn this material?</p>
  <p>UPD: I need description in official notes. Like python.org. How to work AST-analizer optimization for example.</p>
  <p>UPD2: It is desirable without the need to study the CPython source code in depth.</p>