Roundup Robot devnull@devnull 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.
Mark Dickinson dicki...@gmail.com 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
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
assignee: rhettinger - mark.dickinson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
Eugene Toder elto...@gmail.com 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.
--
Antoine Pitrou pit...@free.fr 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 -
Mark Dickinson dicki...@gmail.com 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
Changes by Nadeem Vawda nadeem.va...@gmail.com:
--
nosy: +nvawda
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
___
Python-bugs-list
Mark Dickinson dicki...@gmail.com 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.
--
Eugene Toder elto...@gmail.com added the comment:
Mark, looks better now?
--
Added file: http://bugs.python.org/file21082/fold-0.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
Changes by Eugene Toder elto...@gmail.com:
Removed file: http://bugs.python.org/file21082/fold-0.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
Eugene Toder elto...@gmail.com added the comment:
(forgot parens around 0)
--
Added file: http://bugs.python.org/file21083/fold-0.2.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
Roundup Robot devnull@devnull 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
Antoine Pitrou pit...@free.fr added the comment:
Ok, Eugene's patch is left to apply now. Can I assign this to you, Mark?
--
assignee: - mark.dickinson
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
Raymond Hettinger rhettin...@users.sourceforge.net 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.
Antoine Pitrou pit...@free.fr added the comment:
Eugene's patch looks like a correct fix to the regression.
No, it's orthogonal.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
Eugene Toder elto...@gmail.com added the comment:
Yes, my patch doesn't fix the regression, only a special case of -0.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
Eugene Toder elto...@gmail.com 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,
Antoine Pitrou pit...@free.fr 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 rep...@bugs.python.org
Antoine Pitrou pit...@free.fr added the comment:
Forgot to attach new patch, sorry.
--
Added file: http://bugs.python.org/file20897/constfold2.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
Mark Dickinson dicki...@gmail.com 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
Antoine Pitrou pit...@free.fr added the comment:
Le samedi 19 février 2011 à 10:45 +, Mark Dickinson a écrit :
Mark Dickinson dicki...@gmail.com added the comment:
Unassigning. I don't think that r82043 is the *real* culprit here; that
bugfix just happened to expose a deficiency in
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:
--
nosy: +Arfrever
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
Mark Dickinson dicki...@gmail.com 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.
--
___
New submission from Jeffrey Harper jhar...@yapdc.com:
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
Jeffrey Harper jhar...@yapdc.com 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} #
Changes by Antoine Pitrou pit...@free.fr:
--
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
___
Python-bugs-list
R. David Murray rdmur...@bitdance.com added the comment:
I wonder if this has anything to do with issue 9011?
--
nosy: +mark.dickinson, r.david.murray
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
Antoine Pitrou pit...@free.fr added the comment:
The culprit is r82043: Issue #9011: Remove buggy and unnecessary ST-AST
compilation code.
--
assignee: - mark.dickinson
nosy: +pitrou
___
Python tracker rep...@bugs.python.org
Antoine Pitrou pit...@free.fr 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
Jeffrey Harper jhar...@yapdc.com 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:\tmpc:\Python32\python.exe --version
Python 3.2rc3
Antoine Pitrou pit...@free.fr added the comment:
Ouch. Obviously test_peephole doesn't have enough tests...
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
Changes by Raymond Hettinger rhettin...@users.sourceforge.net:
--
priority: normal - high
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11244
___
Jeffrey Harper jhar...@yapdc.com 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:
Antoine Pitrou pit...@free.fr 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
34 matches
Mail list logo