How is an instance of a custom type (i.e. a user-written class) converted to a dict key in Python 3?
Consider for example the following code, where a class has a single variable that should define whether instances are alike:
class MyClass:
def __init__(self, x):
self.x = x
d = {MyClass(1): 1}
assert d[MyClass(1)] == 1
The assert fails because the two different MyClass instances don't resolve to the same dict key, even though they are alike.