[Python-ideas] Make types.MappingProxyType hashable

Guido van Rossum guido at python.org
Thu Jul 28 18:06:07 EDT 2016


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.

What real-world use case do you have for this?

On Thu, Jul 28, 2016 at 3:01 PM, Emanuel Barry <vgr255 at live.ca> wrote:
> Hello Python-ideas,
> While answering a question earlier today, I realized that
> types.MappingProxyType is immutable and unhashable. It seems to me that if
> all values are hashable (all keys are already guaranteed to be hashable),
> then the mappingproxy itself should be hashable. Should I go ahead and make
> a patch for this, or is this a bad idea?
>
> Cheers,
> -Emanuel
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list