We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c6813d9 commit 91cbe60Copy full SHA for 91cbe60
2 files changed
py/obj.c
@@ -118,6 +118,8 @@ machine_int_t mp_obj_hash(mp_obj_t o_in) {
118
return (machine_int_t)o_in;
119
} else if (MP_OBJ_IS_TYPE(o_in, &mp_type_tuple)) {
120
return mp_obj_tuple_hash(o_in);
121
+ } else if (MP_OBJ_IS_TYPE(o_in, &mp_type_type)) {
122
+ return (machine_int_t)o_in;
123
124
// TODO hash class and instances
125
// TODO delegate to __hash__ method if it exists
tests/basics/types_hash.py
@@ -0,0 +1,6 @@
1
+# Types are hashable
2
+print(hash(type) != 0)
3
+print(hash(int) != 0)
4
+print(hash(list) != 0)
5
+class Foo: pass
6
+print(hash(Foo) != 0)
0 commit comments