[issue11549] Build-out an AST optimizer, moving some functionality out of the peephole optimizer
Nick Coghlan
report at bugs.python.org
Thu Sep 6 02:11:42 CEST 2012
Nick Coghlan added the comment:
All of the optimisations that assume globals haven't been shadowed or rebound are invalid in the general case.
E.g. print(1.5) and print("1.5") are valid for *our* print function, but we technically have no idea if they're equivalent in user code.
In short, if it involves a name lookup and that name isn't reserved to the compiler (e.g. __debug__) then no, you're not allowed to optimise it at compile time if you wish to remain compliant with the language spec. Method calls on literals are always fair game, though (e.g. you could optimise "a b c".split())
Any stdlib AST optimiser would need to be substantially more conservative by default.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11549>
_______________________________________
More information about the Python-bugs-list
mailing list