parse-time optimizations

jcm grumble at usa.net
Wed May 30 09:54:11 EDT 2001


Delaney, Timothy <tdelaney at avaya.com> wrote:
> Very true. Constant folding could only be used in unambiguous situations ...
> and most such things aren't unambiguous :(

> Indeed

>     x + 1 + 2 + 3

> couldn't even be folded down to

>     x + 1 + 5

This is an unambiguous situation.  Don't just think of the program
text--these transformations would be done on the parse-tree.  In
Python '+' is left-associative.  We're talking about simple,
well-understood optimizations.  The reason I am advocating these in
particular is because they can be done without heavyweight semantic
analysis.



More information about the Python-list mailing list