Skip to content

Commit efe8e0c

Browse files
committed
add test and fix multiply
1 parent f29d8be commit efe8e0c

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

Lib/test/test_opcache.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,6 +1268,31 @@ def binary_op_add_unicode():
12681268
self.assert_specialized(binary_op_add_unicode, "BINARY_OP_ADD_UNICODE")
12691269
self.assert_no_opcode(binary_op_add_unicode, "BINARY_OP")
12701270

1271+
def binary_op_add_extend():
1272+
for _ in range(100):
1273+
a, b = 6, 3.0
1274+
c = a + b
1275+
self.assertEqual(c, 9.0)
1276+
c = b + a
1277+
self.assertEqual(c, 9.0)
1278+
c = a - b
1279+
self.assertEqual(c, 3.0)
1280+
c = b - a
1281+
self.assertEqual(c, -3.0)
1282+
c = a * b
1283+
self.assertEqual(c, 18.0)
1284+
c = b * a
1285+
self.assertEqual(c, 18.0)
1286+
c = a / b
1287+
self.assertEqual(c, 2.0)
1288+
c = b / a
1289+
self.assertEqual(c, 0.5)
1290+
1291+
binary_op_add_extend()
1292+
self.assert_specialized(binary_op_add_extend, "BINARY_OP_EXTEND")
1293+
self.assert_no_opcode(binary_op_add_extend, "BINARY_OP")
1294+
1295+
12711296
@cpython_only
12721297
@requires_specialization_ft
12731298
def test_load_super_attr(self):

Python/specialize.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,14 +2430,14 @@ static PyBinaryOpSpecializationDescr float_compactlong_specs[NB_OPARG_LAST+1] =
24302430
[NB_ADD] = {float_compactlong_guard, float_compactlong_add},
24312431
[NB_SUBTRACT] = {float_compactlong_guard, float_compactlong_subtract},
24322432
[NB_TRUE_DIVIDE] = {float_compactlong_guard, float_compactlong_true_div},
2433-
[NB_INPLACE_MULTIPLY] = {float_compactlong_guard, float_compactlong_multiply},
2433+
[NB_MULTIPLY] = {float_compactlong_guard, float_compactlong_multiply},
24342434
};
24352435

24362436
static PyBinaryOpSpecializationDescr compactlong_float_specs[NB_OPARG_LAST+1] = {
24372437
[NB_ADD] = {compactlong_float_guard, compactlong_float_add},
24382438
[NB_SUBTRACT] = {compactlong_float_guard, compactlong_float_subtract},
24392439
[NB_TRUE_DIVIDE] = {compactlong_float_guard, compactlong_float_true_div},
2440-
[NB_INPLACE_MULTIPLY] = {compactlong_float_guard, compactlong_float_multiply},
2440+
[NB_MULTIPLY] = {compactlong_float_guard, compactlong_float_multiply},
24412441
};
24422442

24432443
static int

0 commit comments

Comments
 (0)