Skip to content

Commit e06cf89

Browse files
committed
py: Add few more special methods.
1 parent 3611c1d commit e06cf89

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

py/objtype.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,12 @@ const qstr mp_binary_op_method_name[] = {
368368
*/
369369
[MP_BINARY_OP_ADD] = MP_QSTR___add__,
370370
[MP_BINARY_OP_SUBTRACT] = MP_QSTR___sub__,
371+
#if MICROPY_PY_ALL_SPECIAL_METHODS
372+
[MP_BINARY_OP_MULTIPLY] = MP_QSTR___mul__,
373+
[MP_BINARY_OP_FLOOR_DIVIDE] = MP_QSTR___floordiv__,
374+
[MP_BINARY_OP_TRUE_DIVIDE] = MP_QSTR___truediv__,
375+
#endif
371376
/*
372-
MP_BINARY_OP_MULTIPLY,
373-
MP_BINARY_OP_FLOOR_DIVIDE,
374-
MP_BINARY_OP_TRUE_DIVIDE,
375377
MP_BINARY_OP_MODULO,
376378
MP_BINARY_OP_POWER,
377379
MP_BINARY_OP_INPLACE_OR,
@@ -381,9 +383,9 @@ const qstr mp_binary_op_method_name[] = {
381383
MP_BINARY_OP_INPLACE_RSHIFT,*/
382384
#if MICROPY_PY_ALL_SPECIAL_METHODS
383385
[MP_BINARY_OP_INPLACE_ADD] = MP_QSTR___iadd__,
386+
[MP_BINARY_OP_INPLACE_SUBTRACT] = MP_QSTR___isub__,
384387
#endif
385-
/*MP_BINARY_OP_INPLACE_SUBTRACT,
386-
MP_BINARY_OP_INPLACE_MULTIPLY,
388+
/*MP_BINARY_OP_INPLACE_MULTIPLY,
387389
MP_BINARY_OP_INPLACE_FLOOR_DIVIDE,
388390
MP_BINARY_OP_INPLACE_TRUE_DIVIDE,
389391
MP_BINARY_OP_INPLACE_MODULO,

py/qstrdefs.h

+4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ Q(__le__)
7676
Q(__ge__)
7777
Q(__reversed__)
7878
#if MICROPY_PY_ALL_SPECIAL_METHODS
79+
Q(__mul__)
80+
Q(__truediv__)
81+
Q(__floordiv__)
7982
Q(__iadd__)
83+
Q(__isub__)
8084
#endif
8185

8286
Q(micropython)

0 commit comments

Comments
 (0)