[pypy-commit] pypy default: test (fails on py3) to check for the bytecode optimization of constant tuples

cfbolz pypy.commits at gmail.com
Wed Feb 27 10:53:54 EST 2019


Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: 
Changeset: r96186:4d37ac959895
Date: 2019-02-27 10:46 +0100
http://bitbucket.org/pypy/pypy/changeset/4d37ac959895/

Log:	test (fails on py3) to check for the bytecode optimization of
	constant tuples

diff --git a/pypy/interpreter/astcompiler/test/test_compiler.py b/pypy/interpreter/astcompiler/test/test_compiler.py
--- a/pypy/interpreter/astcompiler/test/test_compiler.py
+++ b/pypy/interpreter/astcompiler/test/test_compiler.py
@@ -1204,3 +1204,17 @@
             source = 'def f(): %s' % source
             counts = self.count_instructions(source)
             assert ops.BINARY_POWER not in counts
+
+    def test_constant_tuples(self):
+        source = """def f():
+            return ((u"a", 1), 2)
+        """
+        counts = self.count_instructions(source)
+        assert ops.BUILD_TUPLE not in counts
+        # also for bytes
+        source = """def f():
+            return ((b"a", 5), 5, 7, 8)
+        """
+        counts = self.count_instructions(source)
+        assert ops.BUILD_TUPLE not in counts
+


More information about the pypy-commit mailing list