[Python-ideas] Expose a child factory using MappingProxyType in builtins

David Mertz mertz at gnosis.cx
Tue Feb 28 12:12:41 EST 2017


The difference in hits might be because MappingProxyType has a funny name
and is in a hidden-ish location.  I.e. not necessarily because it *would
be* less used or useful if it were more exposed.

In either case, the name that makes sense to me would be `frozendict`.
That could very well live in `collections` of course.

On Tue, Feb 28, 2017 at 7:40 AM, Ivan Levkivskyi <levkivskyi at gmail.com>
wrote:

> Searching MappingProxyType on GitHub gives over 10,000 results.
> I think it probably makes sense to make mappingproxy more "visible",
> maybe move it to collections module? (where OrderedDict lives)
>
> I am not sure if it makes sense to move it to builtins. (for comparison
> frozenset gives around 1000,000 results)
>
> --
> Ivan
>
>
>
> On 28 February 2017 at 16:24, Joseph Hackman <josephhackman at gmail.com>
> wrote:
>
>> +1
>>
>> I think this makes a lot of sense. What would you name the built in?
>>
>> -Joseph
>>
>> > On Feb 28, 2017, at 7:17 AM, Michel Desmoulin <
>> desmoulinmichel at gmail.com> wrote:
>> >
>> > We have the immutable frozenset for sets and and tuples for lists.
>> >
>> > But we also have something to manipulate dict as immutable
>> datastructures:
>> >
>> >>>> from types import MappingProxyType as idict
>> >>>> d = idict({'a':1, 'b':2, 'c':3})
>> >>>> d['a'] = 4
>> > Traceback (most recent call last):
>> >  File "<ipython-input-3-c6f93d6278af>", line 1, in <module>
>> >    d['a'] = 4
>> > TypeError: 'mappingproxy' object does not support item assignment
>> >
>> > We could expose this as a built type to allow the last of the most
>> > important data structure in Python to be easily immutable.
>> >
>> > _______________________________________________
>> > 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/
>> _______________________________________________
>> 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/
>>
>
>
> _______________________________________________
> 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/
>



-- 
Keeping medicines from the bloodstreams of the sick; food
from the bellies of the hungry; books from the hands of the
uneducated; technology from the underdeveloped; and putting
advocates of freedom in prisons.  Intellectual property is
to the 21st century what the slave trade was to the 16th.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170228/6ca7a366/attachment.html>


More information about the Python-ideas mailing list