Next: , Previous: , Up: Advanced Compiler Introduction   [Contents][Index]


5.1.2 Optimization

The main barrier to efficient Lisp programs is not that there is no efficient way to code the program in Lisp, but that it is difficult to arrive at that efficient coding. Common Lisp is a highly complex language, and usually has many semantically equivalent “reasonable” ways to code a given problem. It is desirable to make all of these equivalent solutions have comparable efficiency so that programmers don’t have to waste time discovering the most efficient solution.

Source level optimization increases the number of efficient ways to solve a problem. This effect is much larger than the increase in the efficiency of the “best” solution. Source level optimization transforms the original program into a more efficient (but equivalent) program. Although the optimizer isn’t doing anything the programmer couldn’t have done, this high-level optimization is important because:

Source level optimization eliminates the need for macros to optimize their expansion, and also increases the effectiveness of inline expansion. See sections source-optimization and inline-expansion.

Efficient support for a safer programming style is the biggest advantage of source level optimization. Existing tuned programs typically won’t benefit much from source optimization, since their source has already been optimized by hand. However, even tuned programs tend to run faster under Python because:


Next: , Previous: , Up: Advanced Compiler Introduction   [Contents][Index]