[issue11244] Negative tuple elements produce inefficient code.

2011-03-23 Thread Mark Dickinson
Mark Dickinson added the comment: Fixed in 'default' branch. Note that the regression still exists in 3.2; I'm not sure that it's worth backporting the two fixes. -- status: open -> closed ___ Python tracker __

[issue11244] Negative tuple elements produce inefficient code.

2011-03-23 Thread Roundup Robot
Roundup Robot added the comment: New changeset ead9c1b9f547 by Mark Dickinson in branch 'default': Issue #11244: Remove outdated peepholer check that was preventing the peepholer from folding -0 and -0.0. Thanks Eugene Toder for the patch. http://hg.python.org/cpython/rev/ead9c1b9f547 ---

[issue11244] Negative tuple elements produce inefficient code.

2011-03-22 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: rhettinger -> mark.dickinson ___ Python tracker ___ ___ Python-bugs-list mailing list Unsu

[issue11244] Negative tuple elements produce inefficient code.

2011-03-15 Thread Antoine Pitrou
Antoine Pitrou added the comment: Eugene, according to Mark your patch is fine. It just needs someone to commit it. I would personally prefer to let Mark handle it, since he's our specialist in negative zeroes (and other numerical subtleties) ;) -- stage: patch review -> commit review

[issue11244] Negative tuple elements produce inefficient code.

2011-03-15 Thread Eugene Toder
Eugene Toder added the comment: Is anyone reviewing my patch? It's just 1 line long. Should it be moved to another issue? Though, technically, it's needed to address the regression in question: Python 3.1 folds -0, the current code still does not. -- _

[issue11244] Negative tuple elements produce inefficient code.

2011-03-12 Thread Nadeem Vawda
Changes by Nadeem Vawda : -- nosy: +nvawda ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue11244] Negative tuple elements produce inefficient code.

2011-03-12 Thread Mark Dickinson
Mark Dickinson added the comment: Eugene's new patch looks good to me; +1 on applying it. Raymond, do you happen to remember why it was necessary to add the zero-check in the first place? -- ___ Python tracker

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Yes, my patch doesn't fix the regression, only a special case of -0. -- ___ Python tracker ___ ___ Py

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Eugene's patch looks like a correct fix to the regression. No, it's orthogonal. -- ___ Python tracker ___ __

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: Eugene's patch looks like a correct fix to the regression. I'll review further in the next couple of days. Antoine, we need to further discuss your checkin to the peephole optimizer. I believe it was inappropriate. -- assignee: mark.dickinson ->

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ok, Eugene's patch is left to apply now. Can I assign this to you, Mark? -- assignee: -> mark.dickinson ___ Python tracker ___ ___

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Roundup Robot
Roundup Robot added the comment: New changeset 14205d0fee45 by Antoine Pitrou in branch 'default': Issue #11244: The peephole optimizer is now able to constant-fold http://hg.python.org/cpython/rev/14205d0fee45 -- nosy: +python-dev ___ Python tracker

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: (forgot parens around 0) -- Added file: http://bugs.python.org/file21083/fold-0.2.patch ___ Python tracker ___ __

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Eugene Toder
Changes by Eugene Toder : Removed file: http://bugs.python.org/file21082/fold-0.patch ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Eugene Toder
Eugene Toder added the comment: Mark, looks better now? -- Added file: http://bugs.python.org/file21082/fold-0.patch ___ Python tracker ___ _

[issue11244] Negative tuple elements produce inefficient code.

2011-03-11 Thread Mark Dickinson
Mark Dickinson added the comment: fold-0.patch looks good to me, but why do you include tests only for the float case (-0.0) and not the integer case (-0)? Style nitpick: "def negzero(): return -(1.0-1.0)" should be on two source lines, not one. -- _

[issue11244] Negative tuple elements produce inefficient code.

2011-03-10 Thread Eugene Toder
Eugene Toder added the comment: As discussed on the list, peephole refuses to fold -0. The reasons for this are unclear. Folding was disabled with this commit: http://hg.python.org/cpython/diff/660419bdb4ae/Python/compile.c Here's a trivial patch to enable the folding again, along with a test

[issue11244] Negative tuple elements produce inefficient code.

2011-02-25 Thread Antoine Pitrou
Antoine Pitrou added the comment: Forgot to attach new patch, sorry. -- Added file: http://bugs.python.org/file20897/constfold2.patch ___ Python tracker ___

[issue11244] Negative tuple elements produce inefficient code.

2011-02-25 Thread Antoine Pitrou
Antoine Pitrou added the comment: This patch has tests and is also able to constant-fold tuples larger than 256 elements. -- stage: -> patch review versions: +Python 3.3 ___ Python tracker __

[issue11244] Negative tuple elements produce inefficient code.

2011-02-19 Thread Mark Dickinson
Mark Dickinson added the comment: > It should. Can you test? Ah, you're asking me to actually do some (minimal) work instead of just complaining? Yep, the patch tests fine over here (OS X 10.6), and fixes the 2*(3*4) case. -- ___ Python tracker <

[issue11244] Negative tuple elements produce inefficient code.

2011-02-19 Thread Arfrever Frehtes Taifersar Arahesis
Changes by Arfrever Frehtes Taifersar Arahesis : -- nosy: +Arfrever ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscri

[issue11244] Negative tuple elements produce inefficient code.

2011-02-19 Thread Antoine Pitrou
Antoine Pitrou added the comment: Le samedi 19 février 2011 à 10:45 +, Mark Dickinson a écrit : > Mark Dickinson added the comment: > > Unassigning. I don't think that r82043 is the *real* culprit here; that > bugfix just happened to expose a deficiency in the peepholer; one that's >

[issue11244] Negative tuple elements produce inefficient code.

2011-02-19 Thread Mark Dickinson
Mark Dickinson added the comment: Unassigning. I don't think that r82043 is the *real* culprit here; that bugfix just happened to expose a deficiency in the peepholer; one that's already present in other situations: >>> dis.dis(lambda: 2*(3*4)) 1 0 LOAD_CONST 1 (2

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Here is a patch that enables advanced (recursive) constant folding. Example: python -c "import dis; f=lambda x: x in {(3*-5)+(-1-6),(1,-2,3)*2,None};dis.dis(f)" With 3.1: 1 0 LOAD_FAST0 (x) 3 LOAD_CONST

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Jeffrey Harper
Jeffrey Harper added the comment: Here's a patch against the version of test_peepholer.py in 3.2rc3. It verifies that expressions like the following are optimized: 3*-4 (1,-2,3) a in {1,-2,3) -- keywords: +patch Added file: http://bugs.python.org/file20787/test_peepholer.patch _

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- priority: normal -> high ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: Ouch. Obviously test_peephole doesn't have enough tests... -- ___ Python tracker ___ ___ Python-bug

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Jeffrey Harper
Jeffrey Harper added the comment: I think r82043 may also explain why 3.1.3 can fold the expression 2 * -3 into -6 while 3.2rc3 cannot. # test.py from dis import dis def y(): 2 * -3 print("dis y:") dis(y) C:\tmp>c:\Python32\python.exe --version Python 3.2rc3 C:\tmp>c:\Python32\python.exe

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: The problem is that the "UNARY_NEGATIVE + LOAD_CONST" optimization, which occurs first in bytecode order, inserts a NOP and prevents the tuple optimization to work. -- ___ Python tracker

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Antoine Pitrou
Antoine Pitrou added the comment: The culprit is r82043: "Issue #9011: Remove buggy and unnecessary ST->AST compilation code". -- assignee: -> mark.dickinson nosy: +pitrou ___ Python tracker

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread R. David Murray
R. David Murray added the comment: I wonder if this has anything to do with issue 9011? -- nosy: +mark.dickinson, r.david.murray ___ Python tracker ___ _

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Antoine Pitrou
Changes by Antoine Pitrou : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.py

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Jeffrey Harper
Jeffrey Harper added the comment: I have also determined that negative elements interfere with the frozenset optimization described in issue6690. http://bugs.python.org/issue6690. Here's an example program: # test.py from dis import dis def x(var): return var in {1,2,3} # Note curly braces.

[issue11244] Negative tuple elements produce inefficient code.

2011-02-18 Thread Jeffrey Harper
New submission from Jeffrey Harper : In Python 3.2, a tuple like (1,-2,3) will not be optimized into a constants at compile time. The tuple is built at run-time. Earlier versions of Python optimized these tuples at compile time. Here's an example program. # test.py from dis import dis def