From: Guido van Rossum Sent: Thursday, July 28, 2016 6:06 PM To: Emanuel Barry Cc: email@example.com Subject: Re: [Python-ideas] Make types.MappingProxyType hashable
I think you misunderstand the distinction between immutable and read-only. MappingProxyType is read-only -- you cannot modify the underlying dict through the proxy. But it's not immutable -- if the underlying dict is changed directly (e.g. by assignment to a class attribute) the proxy is changed too. So making the proxy hashable would be a mistake.
Oh, I didn't know that this was just a view over an actual dict. I guess that solves the question :)
What real-world use case do you have for this?
Not me, actually. Someone in #python asked about an immutable dict, and I pointed them towards mappingproxy, only to realize it wasn't hashable. Maybe something like frozendict could be added, though? At this point I don't really have an opinion, so it's up to the list to decide if they want it or not :)