<div dir="ltr"><div dir="ltr">One important difference between MappingProxyType and a "proper" frozendict, as analog to frozenset, is that MappingProxyType doesn't have any method to return mutated versions of itself.<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, 11 Oct 2018 at 01:24, Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Philiip, and welcome,<br>
<br>
On Wed, Oct 10, 2018 at 12:04:48PM -0500, Philip Martin wrote:<br>
<br>
> I generally have used MappingProxyType as a way to set default mapping <br>
> to a function or to set an empty mapping to a function.<br>
<br>
> I've created a gist with an example use case:<br>
> <br>
> <a href="https://gist.github.com/pmart123/493edf84d9aa61691ca7321325ebb6ab" rel="noreferrer" target="_blank">https://gist.github.com/pmart123/493edf84d9aa61691ca7321325ebb6ab</a><br>
<br>
Please try to keep the discussion in one place (i.e. here), for the <br>
benefit of the archives and for those who have email access but not <br>
unrestricted web access.<br>
<br>
Can you explain (in English) your use-case, and why MappingProxyType <br>
isn't suitable? If it *is* suitable, how does your proposal differ?<br>
<br>
If the only proposal is to rename types.MappingProxyType to a builtin <br>
"frozendict", that's one thing; if the proposal is something else, you <br>
should explain what.<br>
<br>
<br>
> I've included an example of what code typically looks like when using<br>
> MappingProxyType and what it could look like with a<br>
> frozendict implementation.<br>
<br>
Wouldn't that be just:<br>
<br>
    from types import MappingProxyType as frozendict<br>
    d = frozendict({'spam': 1, 'eggs': 2})<br>
<br>
versus:<br>
<br>
    d = frozendict({'spam': 1, 'eggs': 2})<br>
<br>
Apart from the initial import, how would they be different? You want a <br>
frozendict; the existing MappingProxyType provides a frozendict (with a <br>
surprising name, but never mind...). Wouldn't you use them exactly the <br>
same way? They both (I presume) offer precisely the same read-only <br>
access to the mapping interface.<br>
<br>
<br>
<br>
-- <br>
Steve<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>