Commit 91cbe603 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

py: Allow types to be hashable.

Quite natural to have d[int] = handle_int .
parent c6813d92
......@@ -118,6 +118,8 @@ machine_int_t mp_obj_hash(mp_obj_t o_in) {
return (machine_int_t)o_in;
} else if (MP_OBJ_IS_TYPE(o_in, &mp_type_tuple)) {
return mp_obj_tuple_hash(o_in);
} else if (MP_OBJ_IS_TYPE(o_in, &mp_type_type)) {
return (machine_int_t)o_in;
// TODO hash class and instances
// TODO delegate to __hash__ method if it exists
......
# Types are hashable
print(hash(type) != 0)
print(hash(int) != 0)
print(hash(list) != 0)
class Foo: pass
print(hash(Foo) != 0)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment