[issue29469] AST-level Constant folding

STINNER Victor report at bugs.python.org
Tue Feb 7 03:55:31 EST 2017


STINNER Victor added the comment:

I suggest you to look at my AST optimizer, especially the constant folding part:
https://github.com/haypo/fatoptimizer/blob/master/fatoptimizer/const_fold.py

And the unit tests, search for BaseConstantFoldingTests:
https://github.com/haypo/fatoptimizer/blob/master/test_fatoptimizer.py#L1980

IHMO we must have a long test suite on this AST optimizer, because it's common that the AST changes in subtle ways, AST is complex and so we should prevent regressions. You may simply copy my unit tests.

My optimizer implements more optimization: just remove unit tests on cases which you don't want to optimize.

----------
nosy: +haypo

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29469>
_______________________________________


More information about the Python-bugs-list mailing list