optimization with the "compiler" module
Steve Holden
sholden at holdenweb.com
Tue Apr 16 17:22:00 EDT 2002
<sean.bowman at acm.org> wrote ...
> hello,
>
> I'm wondering if there's a way to optimize code generated using the
> compiler module. for example, if I say::
>
> import dis
> from parser import compileast, expr
>
> code = compileast(expr('x+3+7.'))
> print dis.dis(code)
>
> I notice that the constants aren't folded. is there a way to do this, or
> do I have to fiddle with the ast myself?
>
The interpreter does not perform constant folding, and it is not currently
intended that it should. If someone with sufficient knowledge, skill and
time wants to submit a patch, I am sure that will be regarded with nothing
but delight! :-)
regards
Steve
More information about the Python-list
mailing list