[Python-checkins] cpython: Issue #11244: Remove outdated peepholer check that was preventing the peepholer (original) (raw)

mark.dickinson python-checkins at python.org
Wed Mar 23 19:14:12 CET 2011


http://hg.python.org/cpython/rev/ead9c1b9f547 changeset: 68869:ead9c1b9f547 user: Mark Dickinson <mdickinson at enthought.com> date: Wed Mar 23 17:59:37 2011 +0000 summary: Issue #11244: Remove outdated peepholer check that was preventing the peepholer from folding -0 and -0.0. Thanks Eugene Toder for the patch.

files: Lib/test/test_peepholer.py | 11 +++++++++++ Misc/ACKS | 1 + Misc/NEWS | 3 +++ Python/peephole.c | 6 ++---- 4 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py --- a/Lib/test/test_peepholer.py +++ b/Lib/test/test_peepholer.py @@ -3,6 +3,7 @@ import sys from io import StringIO import unittest +from math import copysign def disassemble(func): f = StringIO() @@ -207,6 +208,9 @@ def test_folding_of_unaryops_on_constants(self): for line, elem in ( ('-0.5', '(-0.5)'), # unary negative + ('-0.0', '(-0.0)'), # -0.0 + ('-(1.0-1.0)','(-0.0)'), # -0.0 after folding + ('-0', '(0)'), # -0 ('~-2', '(1)'), # unary invert ('+1', '(1)'), # unary positive ): @@ -214,6 +218,13 @@ self.assertIn(elem, asm, asm) self.assertNotIn('UNARY_', asm) + # Check that -0.0 works after marshaling + def negzero(): + return -(1.0-1.0) + + self.assertNotIn('UNARY_', disassemble(negzero)) + self.assertTrue(copysign(1.0, negzero()) < 0) + # Verify that unfoldables are skipped for line, elem in ( ('-"abc"', "('abc')"), # unary negative diff --git a/Misc/ACKS b/Misc/ACKS --- a/Misc/ACKS +++ b/Misc/ACKS @@ -867,6 +867,7 @@ Frank J. Tobin R Lindsay Todd Bennett Todd +Eugene Toder Matias Torchinsky Sandro Tosi Richard Townsend diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ Core and Builtins

+- Issue #11244: Remove an unnecessary peepholer check that was preventing

@@ -250,9 +250,7 @@ opcode = codestr[3]; switch (opcode) { case UNARY_NEGATIVE:

-- Repository URL: http://hg.python.org/cpython



More information about the Python-checkins mailing list