[issue29469] AST-level Constant folding

2017-12-17 Thread INADA Naoki
INADA Naoki added the comment: New changeset 87010e85cb37192d63b1a30e5fabba307ad5a3f5 by INADA Naoki in branch 'master': bpo-29469: peephole: Remove const_stack (GH-4879) https://github.com/python/cpython/commit/87010e85cb37192d63b1a30e5fabba307ad5a3f5 --

[issue29469] AST-level Constant folding

2017-12-15 Thread INADA Naoki
INADA Naoki added the comment: > ISTM, the constant-tracking macros for peephole.c can also be removed, > essentially reverting back to the simpler cumlc-style code in Py2.5. I tried it in GH-4879. -- ___ Python tracker

[issue29469] AST-level Constant folding

2017-12-15 Thread INADA Naoki
Change by INADA Naoki : -- pull_requests: +4773 ___ Python tracker ___ ___

[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- status: open -> closed ___ Python tracker ___

[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: New changeset 15a8728415e765f57e37f431f09e5c5821a04063 by Serhiy Storchaka in branch 'master': bpo-29469: Optimize literal lists and sets iterating on the AST level. (#4866)

[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: PR 4866 also fixes the bug in optimizing chained 'i' and 'not in'. For example `1 in [1, 2] == [1, 2]` results in False (should be True) because it is changed to `1 in (1, 2) == [1, 2]`, and (1, 2) != [1, 2]. --

[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- pull_requests: +4757 ___ Python tracker ___ ___

[issue29469] AST-level Constant folding

2017-12-14 Thread Serhiy Storchaka
Change by Serhiy Storchaka : -- status: closed -> open ___ Python tracker ___

[issue29469] AST-level Constant folding

2017-12-14 Thread STINNER Victor
STINNER Victor added the comment: Thank you very much Naoki for taking time to implement this obvious "optimization", rewriting the peephole optimizer at the AST level, rather than modifying bytecode which is more complex to get it right and had annoying side effect

[issue29469] AST-level Constant folding

2017-12-14 Thread INADA Naoki
INADA Naoki added the comment: New changeset eadad1b97f64619bfd246b9d3b60d25f456e0592 by INADA Naoki in branch 'master': bpo-29469: Remove unnecessary peephole optimizer (GH-4863) https://github.com/python/cpython/commit/eadad1b97f64619bfd246b9d3b60d25f456e0592

[issue29469] AST-level Constant folding

2017-12-14 Thread INADA Naoki
Change by INADA Naoki : -- pull_requests: +4753 ___ Python tracker ___ ___

[issue29469] AST-level Constant folding

2017-12-14 Thread Raymond Hettinger
Raymond Hettinger added the comment: ISTM, the constant-tracking macros for peephole.c can also be removed, essentially reverting back to the simpler cumlc-style code in Py2.5. -- nosy: +rhettinger ___ Python tracker

[issue29469] AST-level Constant folding

2017-12-13 Thread INADA Naoki
Change by INADA Naoki : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue29469] AST-level Constant folding

2017-12-13 Thread INADA Naoki
INADA Naoki added the comment: New changeset 7ea143ae795a9fd57eaccf490d316bdc13ee9065 by INADA Naoki in branch 'master': bpo-29469: Move constant folding to AST optimizer (GH-2858) https://github.com/python/cpython/commit/7ea143ae795a9fd57eaccf490d316bdc13ee9065

[issue29469] AST-level Constant folding

2017-07-25 Thread INADA Naoki
Changes by INADA Naoki : -- pull_requests: +2909 ___ Python tracker ___ ___

[issue29469] AST-level Constant folding

2017-07-03 Thread STINNER Victor
STINNER Victor added the comment: Naoki: Can you please create a PR for your patch? -- ___ Python tracker ___

[issue29469] AST-level Constant folding

2017-07-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: In general the patch LGTM. I haven't found bugs. I think that at this stage we can asdl_ct.py and ast_opt.ct and use just their result, ast_opt.c (maybe rename to optimize.c?) The grammar is not often changed, and in that case it would be not hard to modify

[issue29469] AST-level Constant folding

2017-02-07 Thread INADA Naoki
INADA Naoki added the comment: Do you mean https://github.com/pypa/pip/blob/403e398330c8e841e4633aceda859430f5f7b913/pip/_vendor/distlib/markers.py ? This doesn't affect, maybe. Constant folding is executed right before producing bytecode. It doesn't affect to PyCF_ONLY_AST. BTW, how do you

[issue29469] AST-level Constant folding

2017-02-07 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- components: +Interpreter Core nosy: +benjamin.peterson, brett.cannon, georg.brandl, ncoghlan, serhiy.storchaka, yselivanov stage: -> patch review type: -> enhancement ___ Python tracker

[issue29469] AST-level Constant folding

2017-02-07 Thread STINNER Victor
STINNER Victor added the comment: With this change, the Python compiler doesn't emit ast.Num nor ast.Str, right? If we merge such change, we should prepare projects using AST. There is something like that in pip, but I failed to remind which one :-/ It should be easy: apply your patch, try to

[issue29469] AST-level Constant folding

2017-02-07 Thread STINNER Victor
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:

[issue29469] AST-level Constant folding

2017-02-06 Thread INADA Naoki
Changes by INADA Naoki : -- dependencies: +Change docstring to attribute from first statement. ___ Python tracker ___

[issue29469] AST-level Constant folding

2017-02-06 Thread INADA Naoki
New submission from INADA Naoki: spin off of #11549. This patch uses code generator to traverse AST. -- files: ast-constant-folding.patch keywords: patch messages: 287186 nosy: inada.naoki priority: normal severity: normal status: open title: AST-level Constant folding versions: Python