title: Optimization of arithmetic expressions - what is this technique called?
body: <p>A discussion with a friend led to the following realization:</p>
  
  <pre><code>&gt;&gt;&gt; import dis
  &gt;&gt;&gt; i = lambda n: n*24*60*60
  &gt;&gt;&gt; dis.dis(i)
    1           0 LOAD_FAST                0 (n)
                3 LOAD_CONST               1 (24)
                6 BINARY_MULTIPLY
                7 LOAD_CONST               2 (60)
               10 BINARY_MULTIPLY
               11 LOAD_CONST               2 (60)
               14 BINARY_MULTIPLY
               15 RETURN_VALUE
  &gt;&gt;&gt; k = lambda n: 24*60*60*n
  &gt;&gt;&gt; dis.dis(k)
    1           0 LOAD_CONST               4 (86400)
                3 LOAD_FAST                0 (n)
                6 BINARY_MULTIPLY
                7 RETURN_VALUE
  </code></pre>
  
  <p>The second example is clearly more efficient simply by reducing the number of instructions.</p>
  
  <p>My question is, is there a name for this optimization, and why doesn't it happen in the first example?</p>
  
  <p>Also, I'm not sure if this is a duplicate of <a href="https://stackoverflow.com/questions/6430448/why-doesnt-gcc-optimize-aaaaaa-to-aaaaaa">Why doesn&#39;t GCC optimize a*a*a*a*a*a to (a*a*a)*(a*a*a)?</a> ; if it is please explain a bit further as it applies to Python.</p>