Code: Select all
m1 = 5
del m1
Code: Select all
STATIC mp_obj_t dict_get_helper(size_t n_args, const mp_obj_t *args, mp_map_lookup_kind_t lookup_kind) {
mp_check_self(MP_OBJ_IS_DICT_TYPE(args[0]));
mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]);
mp_map_elem_t *elem = mp_map_lookup(&self->map, args[1], lookup_kind);
mp_obj_t value;
if (elem == NULL || elem->value == MP_OBJ_NULL) {
if (n_args == 2) {
if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) {
nlr_raise(mp_obj_new_exception_arg1(&mp_type_KeyError, args[1]));
} else {
value = mp_const_none;
}
} else {
value = args[2];
}
if (lookup_kind == MP_MAP_LOOKUP_ADD_IF_NOT_FOUND) {
elem->value = value;
}
} else {
value = elem->value;
if (lookup_kind == MP_MAP_LOOKUP_REMOVE_IF_FOUND) {
elem->value = MP_OBJ_NULL; // so that GC can collect the deleted value
}
}
return value;
}
Code: Select all
elem->value = MP_OBJ_NULL; // so that GC can collect the deleted value
I care about this because I have the following code
Code: Select all
while True:
m1 = my_queue1.get()
my_queue2.put(m1)
del m1
so after enough time, the gc will be triggered EVEN IF I call "del m1"
I would like for "del m1" to also call "m_free" to free underlying memory.
This would eliminate the need to call gc (and the resulting overhead)