[issue32344] Explore whether peephole.c tuple of constants folding can be an AST transformation

2017-12-16 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Tuples represented in AST already are optimized at AST level. But there are tuples created at compilation stage (see the code emitting BUILD_TUPLE). Inada's PR 4879 simplifies the peephole optimizer. I tried to move this optimization at the compiler level,

[issue32344] Explore whether peephole.c tuple of constants folding can be an AST transformation

2017-12-16 Thread Raymond Hettinger
New submission from Raymond Hettinger : Can the peephole optimizer's fold_tuple_on_constants() be moved to ast_opt? It looks to me like there is sufficient information in the tree: import ast print(ast.dump(ast.parse('c = (50+1, 60+2)'))) --- Module(