You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Negative tuple elements produce inefficient code. #55453
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/mdickinson'closed_at=<Date2011-03-23.18:20:49.447>created_at=<Date2011-02-18.17:41:04.894>labels= ['performance']
title='Negative tuple elements produce inefficient code.'updated_at=<Date2011-03-23.18:20:49.446>user='https://bugs.python.org/jdharper'
Here's a trivial patch to enable the folding again, along with a test case. make test passes with the patch.
The change is independent from Antoine's patches.
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?
eltoder commented on Mar 15, 2011
eltodermannequin
Mannequin
More actions
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.
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) ;)
New changeset ead9c1b9f547 by Mark Dickinson in branch 'default':
Issue bpo-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
Activity
pitrou commentedon Feb 25, 2011
This patch has tests and is also able to constant-fold tuples larger than 256 elements.
pitrou commentedon Feb 25, 2011
Forgot to attach new patch, sorry.
eltoder commentedon Mar 10, 2011
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 case. make test passes with the patch.
The change is independent from Antoine's patches.
mdickinson commentedon Mar 11, 2011
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.
eltoder commentedon Mar 11, 2011
Mark, looks better now?
eltoder commentedon Mar 11, 2011
(forgot parens around 0)
python-dev commentedon Mar 11, 2011
New changeset 14205d0fee45 by Antoine Pitrou in branch 'default':
Issue bpo-11244: The peephole optimizer is now able to constant-fold
http://hg.python.org/cpython/rev/14205d0fee45
pitrou commentedon Mar 11, 2011
Ok, Eugene's patch is left to apply now. Can I assign this to you, Mark?
rhettinger commentedon Mar 11, 2011
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.
pitrou commentedon Mar 11, 2011
No, it's orthogonal.
eltoder commentedon Mar 11, 2011
Yes, my patch doesn't fix the regression, only a special case of -0.
mdickinson commentedon Mar 12, 2011
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?
eltoder commentedon Mar 15, 2011
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.
pitrou commentedon Mar 15, 2011
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) ;)
python-dev commentedon Mar 23, 2011
New changeset ead9c1b9f547 by Mark Dickinson in branch 'default':
Issue bpo-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
mdickinson commentedon Mar 23, 2011
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.