Skip to content

Commit 6476205

Browse files
committed
add inplace ops
1 parent 6916df4 commit 6476205

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Lib/test/test_opcache.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,15 @@ def binary_op_bitwise_extend():
13711371
self.assertEqual(y, 2)
13721372
z = a ^ b
13731373
self.assertEqual(z, 5)
1374+
a, b = 3, 9
1375+
a |= b
1376+
self.assertEqual(a, 11)
1377+
a, b = 11, 9
1378+
a &= b
1379+
self.assertEqual(a, 9)
1380+
a, b = 3, 9
1381+
a ^= b
1382+
self.assertEqual(a, 10)
13741383

13751384
binary_op_bitwise_extend()
13761385
self.assert_specialized(binary_op_bitwise_extend, "BINARY_OP_EXTEND")

Python/specialize.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2514,6 +2514,9 @@ static _PyBinaryOpSpecializationDescr compactlongs_specs[NB_OPARG_LAST+1] = {
25142514
[NB_OR] = {compactlongs_guard, compactlongs_or},
25152515
[NB_AND] = {compactlongs_guard, compactlongs_and},
25162516
[NB_XOR] = {compactlongs_guard, compactlongs_xor},
2517+
[NB_INPLACE_OR] = {compactlongs_guard, compactlongs_or},
2518+
[NB_INPLACE_AND] = {compactlongs_guard, compactlongs_and},
2519+
[NB_INPLACE_XOR] = {compactlongs_guard, compactlongs_xor},
25172520
};
25182521

25192522
static _PyBinaryOpSpecializationDescr float_compactlong_specs[NB_OPARG_LAST+1] = {

0 commit comments

Comments
 (0)