| This fundamentally reduces the usefulness of hash representations though. Instead of thinking of dict keys, think sets. It's also worth pointing out that user-defined objects operate the way you seem to desire (e.g. default to using the id() property of the object to derive the hash). So in my mind, this strikes the perfect balance? StdLib types that are immutable bake in more comparative hash properties while making it trivial for a user to wrap them and override this richer behavior with default hash based on id(). Consider: ``` >>> class myList(object): ... def __init__(self): ... self.inner_list = list() ... >>> x = myList() >>> x <myList object at 0x10bdabf10> >>> x.inner_list [] >>> y = {x: 'hi'} >>> y {<myList object at 0x10bdabf10>: 'hi'} >>> x.inner_list.append(1) >>> x.inner_list [1] >>> y {<myList object at 0x10bdabf10>: 'hi'} >>> for k in y.keys(): ... print k.inner_list ... [1] ``` |
By the way, I'm not talking about any particular implementation.