Next: , Previous: , Up: Source Optimization   [Contents][Index]


5.4.3 Unused Expression Elimination

If the value of any expression is not used, and the expression has no side-effects, then it is deleted. As with constant folding, this optimization applies most often when cleaning up after inline expansion and other optimizations. Any function declared an extensions:constant-function is also subject to unused expression elimination.

Note that Python will eliminate parts of unused expressions known to be side-effect free, even if there are other unknown parts. For example:

(let ((a (list (foo) (bar))))
  (if t
      (zow)
      (raz a)))

becomes:

(progn (foo) (bar))
(zow)