STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) { assert(n_args > 0); assert(MP_OBJ_IS_TYPE(args[0], &mp_type_set)); mp_obj_set_t *self; if (update) { self = args[0]; } else { self = set_copy(args[0]); } for (int i = 1; i < n_args; i++) { mp_obj_t other = args[i]; if (self == other) { set_clear(self); } else { mp_obj_t iter = mp_getiter(other); mp_obj_t next; while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { set_discard(self, next); } } } return self; }
STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) { assert(n_args > 0); mp_obj_set_t *self; if (update) { check_set(args[0]); self = args[0]; } else { check_set_or_frozenset(args[0]); self = set_copy_as_mutable(args[0]); } for (int i = 1; i < n_args; i++) { mp_obj_t other = args[i]; if (self == other) { set_clear(self); } else { mp_obj_t iter = mp_getiter(other); mp_obj_t next; while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) { set_discard(self, next); } } } self->base.type = ((mp_obj_set_t*)args[0])->base.type; return self; }