summaryrefslogtreecommitdiffstatshomepage
path: root/py/objset.c
diff options
context:
space:
mode:
authorJohn R. Lenton <jlenton@gmail.com>2014-01-14 23:58:05 +0000
committerJohn R. Lenton <jlenton@gmail.com>2014-01-14 23:58:05 +0000
commitff8007c7d6497b108e8abe80ab3311945a03fe52 (patch)
treee2f6974d6476cc46b7414ba0626cb519142c3e3d /py/objset.c
parent9daa78943e58602f74c89a2b5b1ed225f4ccf6cc (diff)
parentc6920d31e2b03205fe2851f74a6a4b48d0165608 (diff)
downloadmicropython-ff8007c7d6497b108e8abe80ab3311945a03fe52.tar.gz
micropython-ff8007c7d6497b108e8abe80ab3311945a03fe52.zip
Merge remote-tracking branch 'upstream/master' into builtins
Diffstat (limited to 'py/objset.c')
-rw-r--r--py/objset.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/py/objset.c b/py/objset.c
index e41f2c47f4..ba083ada8a 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -45,6 +45,7 @@ void set_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj
print(env, "}");
}
+
static mp_obj_t set_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args) {
switch (n_args) {
case 0:
@@ -405,6 +406,13 @@ static mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
return set_issuperset(lhs, rhs);
case RT_COMPARE_OP_NOT_EQUAL:
return MP_BOOL(set_equal(lhs, rhs) == mp_const_false);
+ case RT_COMPARE_OP_IN:
+ case RT_COMPARE_OP_NOT_IN:
+ {
+ mp_obj_set_t *o = lhs;
+ mp_obj_t elem = mp_set_lookup(&o->set, rhs, MP_MAP_LOOKUP);
+ return MP_BOOL((op == RT_COMPARE_OP_IN) ^ (elem == NULL));
+ }
default:
// op not supported
return NULL;