summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_opcache.py
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2025-01-16 15:22:13 (GMT)
committerGitHub <noreply@github.com>2025-01-16 15:22:13 (GMT)
commit3893a92d956363fa2443bc5e47d4bae3deddacef (patch)
treee87b4c94dfa6cc47ba4610d93db82dd15791a2fa /Lib/test/test_opcache.py
parente81fe940c9bd092f6de558fa965100502b78da0f (diff)
downloadcpython-3893a92d956363fa2443bc5e47d4bae3deddacef.zip
cpython-3893a92d956363fa2443bc5e47d4bae3deddacef.tar.gz
cpython-3893a92d956363fa2443bc5e47d4bae3deddacef.tar.bz2
gh-100239: specialize long tail of binary operations (#128722)
Diffstat (limited to 'Lib/test/test_opcache.py')
-rw-r--r--Lib/test/test_opcache.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_opcache.py b/Lib/test/test_opcache.py
index b80ccbf..72b845f 100644
--- a/Lib/test/test_opcache.py
+++ b/Lib/test/test_opcache.py
@@ -1338,6 +1338,31 @@ class TestSpecializer(TestBase):
self.assert_specialized(binary_op_add_unicode, "BINARY_OP_ADD_UNICODE")
self.assert_no_opcode(binary_op_add_unicode, "BINARY_OP")
+ def binary_op_add_extend():
+ for _ in range(100):
+ a, b = 6, 3.0
+ c = a + b
+ self.assertEqual(c, 9.0)
+ c = b + a
+ self.assertEqual(c, 9.0)
+ c = a - b
+ self.assertEqual(c, 3.0)
+ c = b - a
+ self.assertEqual(c, -3.0)
+ c = a * b
+ self.assertEqual(c, 18.0)
+ c = b * a
+ self.assertEqual(c, 18.0)
+ c = a / b
+ self.assertEqual(c, 2.0)
+ c = b / a
+ self.assertEqual(c, 0.5)
+
+ binary_op_add_extend()
+ self.assert_specialized(binary_op_add_extend, "BINARY_OP_EXTEND")
+ self.assert_no_opcode(binary_op_add_extend, "BINARY_OP")
+
+
@cpython_only
@requires_specialization_ft
def test_load_super_attr(self):