diff options
Diffstat (limited to 'py')
-rw-r--r-- | py/objtuple.c | 9 | ||||
-rw-r--r-- | py/objtuple.h | 7 | ||||
-rw-r--r-- | py/runtime.c | 12 |
3 files changed, 21 insertions, 7 deletions
diff --git a/py/objtuple.c b/py/objtuple.c index 5c1169ed55..15e74636f8 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -9,19 +9,14 @@ #include "obj.h" #include "runtime0.h" #include "runtime.h" - -typedef struct _mp_obj_tuple_t { - mp_obj_base_t base; - machine_uint_t len; - mp_obj_t items[]; -} mp_obj_tuple_t; +#include "objtuple.h" static mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur); /******************************************************************************/ /* tuple */ -static void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in) { +void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in) { mp_obj_tuple_t *o = o_in; print(env, "("); for (int i = 0; i < o->len; i++) { diff --git a/py/objtuple.h b/py/objtuple.h new file mode 100644 index 0000000000..9c672fe3f5 --- /dev/null +++ b/py/objtuple.h @@ -0,0 +1,7 @@ +typedef struct _mp_obj_tuple_t { + mp_obj_base_t base; + machine_uint_t len; + mp_obj_t items[]; +} mp_obj_tuple_t; + +void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in); diff --git a/py/runtime.c b/py/runtime.c index 4335831ae4..dc3d15657c 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -463,6 +463,18 @@ mp_obj_t rt_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { // then fail // note that list does not implement + or +=, so that inplace_concat is reached first for += + // deal with is, is not + if (op == RT_COMPARE_OP_IS) { + // TODO: may need to handle strings specially, CPython appears to + // assume all strings are interned (so "is" == "==" for strings) + return MP_BOOL(lhs == rhs); + } + if (op == RT_COMPARE_OP_IS_NOT) { + // TODO: may need to handle strings specially, CPython appears to + // assume all strings are interned (so "is" == "==" for strings) + return MP_BOOL(lhs != rhs); + } + // deal with == and != for all types if (op == RT_COMPARE_OP_EQUAL || op == RT_COMPARE_OP_NOT_EQUAL) { if (mp_obj_equal(lhs, rhs)) { |