summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-01-03 14:09:31 +0000
committerDamien George <damien.p.george@gmail.com>2014-01-03 14:09:31 +0000
commit14f945c2cab2b44fcb75675eb1ec8eea8774660b (patch)
tree515bbe52868ec0287c2bf379d0ddcd05ff6b4117 /py
parent66028ab6dcd1b2ec9504c3473d817649935a4a1e (diff)
downloadmicropython-14f945c2cab2b44fcb75675eb1ec8eea8774660b.tar.gz
micropython-14f945c2cab2b44fcb75675eb1ec8eea8774660b.zip
Add note about implementing inplace operators.
Diffstat (limited to 'py')
-rw-r--r--py/runtime.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index a8e55467bd..3144321f3a 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -471,6 +471,16 @@ mp_obj_t rt_unary_op(int op, mp_obj_t arg) {
mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
DEBUG_OP_printf("binary %d %p %p\n", op, lhs, rhs);
+
+ // TODO correctly distinguish inplace operators for mutable objects
+ // lookup logic that CPython uses for +=:
+ // check for implemented +=
+ // then check for implemented +
+ // then check for implemented seq.inplace_concat
+ // then check for implemented seq.concat
+ // then fail
+ // note that list does not implement + or +=, so that inplace_concat is reached first for +=
+
if (MP_OBJ_IS_SMALL_INT(lhs) && MP_OBJ_IS_SMALL_INT(rhs)) {
mp_small_int_t lhs_val = MP_OBJ_SMALL_INT_VALUE(lhs);
mp_small_int_t rhs_val = MP_OBJ_SMALL_INT_VALUE(rhs);