On Fri., 13 Dec. 2019, 5:26 pm mental na via Python-Dev, <python-dev@python.org> wrote:
Guido van Rossum wrote:
> This is most definitely a language issue, not just a CPython issue -- the
> rules around hashability and (im)mutability are due to the language
> definition, not the whim of an implementer.

I was not aware of this, I assumed it was a implementation issue because
I knew CPython's dicts use a hash table implementation and there are other
ways to implement a mapping data structure i.e. via trees.

Guido could you provide a link to the language definition that dictates these
rules about hashability and (im)mutability?

https://docs.python.org/3/reference/datamodel.html#object.__hash__

Many of the special method descriptions spell out the semantic requirements of well-behaved objects (and we then abide by those requirements when implementing builtin types and standard library modules)


> A tool like mypy will catch this for you.

Perhaps I should raise this as a mypy issue then?

Aye, a typechecker failing to catch this situation would definitely be a reasonable issue to raise.

We'd never check for it in the compiler, as it wouldn't be worth the additional state tracking needed for even the local type inference you suggest.

Cheers,
Nick.