[issue26146] PEP 511: Add ast.Constant to allow AST optimizer to emit constants

STINNER Victor report at bugs.python.org
Fri Jan 22 08:05:11 EST 2016


STINNER Victor added the comment:

Patch version 2:

- rework the whole patch
- add unit tests
- fix AST validation: the code was completly wrong in patch 1, I don't understand how it worked :-p Validate also correctly nested tuple and nested frozenset.
- add a comment to explain why obj2ast_constant() doesn't have to Py_INCREF() singletons
- handle also Ellipsis
- revert changes on set_context(). It seems like set_context() is only called with code emited directly by the compiler (not by compile(custom_ast_tree, ...)). If someone finds a way to call set_context() with an ast.Constant, we can support this case later.

----------
Added file: http://bugs.python.org/file41689/constant-2.patch

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


More information about the Python-bugs-list mailing list