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

2016-01-27 Thread Roundup Robot
Roundup Robot added the comment: New changeset 16f60cd918e0 by Victor Stinner in branch 'default': PEP 511 https://hg.python.org/peps/rev/16f60cd918e0 -- ___ Python tracker ___ _

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

2016-01-26 Thread Roundup Robot
Roundup Robot added the comment: New changeset 0d0d0a05 by Victor Stinner in branch 'default': Issue #26146: remove useless code https://hg.python.org/cpython/rev/0d0d0a05 New changeset 58086f0a953a by Victor Stinner in branch 'default': Issue #26146: enhance ast.Constant error message h

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

2016-01-26 Thread Roundup Robot
Roundup Robot added the comment: New changeset c5df914e73ad by Victor Stinner in branch 'default': Fix a refleak in validate_constant() https://hg.python.org/cpython/rev/c5df914e73ad -- ___ Python tracker _

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

2016-01-25 Thread STINNER Victor
STINNER Victor added the comment: I pushed an enhanced version of constant-3.patch: * fix the compiler: don't emit LOAD_CONST for ast.Constant if the value is a string (str) or a number (int, float, complex), as done previously for ast.Str and ast.Num * add unit tests on: the compiler (ensure

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

2016-01-25 Thread Roundup Robot
Roundup Robot added the comment: New changeset 27e5437f442c by Victor Stinner in branch 'default': Add ast.Constant https://hg.python.org/cpython/rev/27e5437f442c -- ___ Python tracker _

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

2016-01-25 Thread STINNER Victor
STINNER Victor added the comment: Patch version 3: fix a reference leak in validate_constant(). -- Added file: http://bugs.python.org/file41708/constant-3.patch ___ Python tracker __

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

2016-01-23 Thread STINNER Victor
STINNER Victor added the comment: > New changeset 5de1bd759f3b by Victor Stinner in branch 'default': > Issue #26146: marshal.loads() now uses the empty frozenset singleton > https://hg.python.org/cpython/rev/5de1bd759f3b This change is not directly related to this issue. It's required by test_

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

2016-01-23 Thread Roundup Robot
Roundup Robot added the comment: New changeset 5de1bd759f3b by Victor Stinner in branch 'default': Issue #26146: marshal.loads() now uses the empty frozenset singleton https://hg.python.org/cpython/rev/5de1bd759f3b -- nosy: +python-dev ___ Python trac

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

2016-01-23 Thread STINNER Victor
STINNER Victor added the comment: @Serhiy: Would you mind reviewing constant-2.patch? I reviewed my own patch and added some comments, I found a refleak ;-) -- ___ Python tracker __

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

2016-01-22 Thread STINNER Victor
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_con

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

2016-01-21 Thread STINNER Victor
Changes by STINNER Victor : -- dependencies: +code_richcompare() don't use constant type when comparing code constants ___ Python tracker ___ ___

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

2016-01-21 Thread STINNER Victor
STINNER Victor added the comment: > We also make no backwards-compatibility guarantees about the AST, so if it > simplifies things to switch entirely to Constant from Num, etc. then I said > do it. Replacing Num/Str/... with Constant causes bug in markerlib (used by pip, it breaks indirectly

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

2016-01-19 Thread STINNER Victor
STINNER Victor added the comment: First I also wanted to add ast.Literal to literals: list, set, dict, etc. But it doesn't work, we loose the item order: set and dict are unordered. An optimizer must not change the order in which items are created. At least, not by default. I'm talking about

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

2016-01-18 Thread STINNER Victor
STINNER Victor added the comment: Brett Cannon: "Would it make sense to tag the type of the constant in the node somehow?" It's easy to get the type of a constant: type(node.value). I like using isinstance(). Brett Cannon: "We also make no backwards-compatibility guarantees about the AST, so

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

2016-01-18 Thread Brett Cannon
Brett Cannon added the comment: Would it make sense to tag the type of the constant in the node somehow? We also make no backwards-compatibility guarantees about the AST, so if it simplifies things to switch entirely to Constant from Num, etc. then I said do it. -- __

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

2016-01-18 Thread STINNER Victor
STINNER Victor added the comment: To support emiting constants from ast.Constant, we will also need the fix for the issue #25843. Currently, the compile merges constants (0, 0) and (0.0, 0.0) because they are equal, but item types are different. --

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

2016-01-18 Thread STINNER Victor
New submission from STINNER Victor: Currently, the Python parser emits ast.Tuple AST nodes which are compiled to multiple LOAD_xxx instructions followed a final BUILD_TUPLE instruction. The Python peephole optimizer detect LOAD_CONST x n + BUILD_TUPLE instructions to replace it directly with a