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 <rep...@bugs.python.org> <http://bugs.python.org/issue29469> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com