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 vstinner
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:25:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1346891124.68.0.68758471549.issue11549@psf.upfronthosting.co.za>
In-reply-to
Content
> All of the optimisations that assume globals haven't been shadowed
> or rebound are invalid in the general case.

My main idea is that the developer of the application should be able to annotate functions and constants to declare them as "optimizable" (constant). I chose to expect builtins as not being overrided, but if it breaks applications, it can be converted to an option disabled by default.

There is a known issue: test_math fails because pow() is an alias to matH.pow() in doctests. The problem is that "from math import *" is called and the result is stored in a namespace, and then "pow(2,4)" is called in the namespace. astoptimizer doesn't detect that pow=math.pow because locals are only set when the code is executed (and not at compilation) with something like: exec(code, namespace). It is a limitation of the optimizer. A workaround is to disable optimizations when running tests.

It is possible to detect that builtins are shadowed (ex: print=myprint). astoptimizer has an experimental support of assignments, but it only works on trivial examples yet (like "x=1; print(x)") and is disabled by default (because it is buggy). I also plan to disable some optimizations if globals(), vars() or dir() is called.
History
Date User Action Args
2012-09-06 00:25:24vstinnersetrecipients: + vstinner, brett.cannon, georg.brandl, rhettinger, terry.reedy, gregory.p.smith, mark.dickinson, ncoghlan, pitrou, techtonik, nadeem.vawda, benjamin.peterson, alex, Trundle, dmalcolm, meador.inge, daniel.urban, Jeremy.Hylton, santoso.wijaya, eltoder, eric.snow, jcon
2012-09-06 00:25:24vstinnersetmessageid: <1346891124.68.0.68758471549.issue11549@psf.upfronthosting.co.za>
2012-09-06 00:25:24vstinnerlinkissue11549 messages
2012-09-06 00:25:22vstinnercreate