This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients Jeremy.Hylton, Trundle, alex, benjamin.peterson, brett.cannon, daniel.urban, dmalcolm, eltoder, eric.snow, georg.brandl, gregory.p.smith, jcon, mark.dickinson, meador.inge, nadeem.vawda, ncoghlan, pitrou, rhettinger, santoso.wijaya, techtonik, terry.reedy, vstinner
Date 2012-09-06.00:11:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.
Date User Action Args
2012-09-06 00:11:42ncoghlansetrecipients: + ncoghlan, brett.cannon, georg.brandl, rhettinger, terry.reedy, gregory.p.smith, mark.dickinson, pitrou, vstinner, techtonik, nadeem.vawda, benjamin.peterson, alex, Trundle, dmalcolm, meador.inge, daniel.urban, Jeremy.Hylton, santoso.wijaya, eltoder, eric.snow, jcon
2012-09-06 00:11:42ncoghlansetmessageid: <>
2012-09-06 00:11:42ncoghlanlinkissue11549 messages
2012-09-06 00:11:41ncoghlancreate