On 8/11/2012 2:30 PM, Victor Stinner wrote:
Hi,
I started to implement an AST optimizer in Python. It's easy to create
a new AST tree, so I'm surprised that I didn't find any existing
project.
https://bitbucket.org/haypo/misc/src/tip/python/ast_optimizer.py
To test its peephole optimizations (by checking manually its final
bytecode), I wrote a patch for Python to disable Python internal
peephole optimizer (on bytecode):
https://bitbucket.org/haypo/misc/src/tip/python/compile_disable_peephole.patch
I would very much like to see the ability to disable all optimizers. As
work continues on the various forms of optimization, please remember
that sometimes programs are executed to reason about them, for example,
when measuring test coverage, or when debugging. Just as gcc has a -O0
option to disable all code optimizations so that you can more easily
debug programs, it would be fabulous for CPython to have an option to
disable all code optimizations. This would include the existing
peephole optimizer as well as any new optimizers such as Victor's AST
optimizer.
Full disclosure: I previously raised this possibility in ticket, and it
was not as popular as I had hoped: http://bugs.python.org/issue2506
--Ned.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com