What makes a user-defined class unhashable?
问题 The docs say that a class is hashable as long as it defines __hash__ method and __eq__ method. However: class X(list): # read-only interface of `tuple` and `list` should be the same, so reuse tuple.__hash__ __hash__ = tuple.__hash__ x1 = X() s = {x1} # TypeError: unhashable type: 'X' What makes X unhashable? Note that I must have identical lists (in terms of regular equality) to be hashed to the same value; otherwise, I will violate this requirement on hash functions: The only required