Thanks for the reminder Victor. For a read-only *dict*, I proposed PEP 416 "Add a frozendict builtin > type" in 2012. It was rejected. > https://peps.python.org/pep-0416/
Note that that was ten years ago -- so maybe worth revisiting. The outcome of this PEP was the addition of the types.MappingProxy > type (previously, it already existed but it was somehow hidden: > type(int.__dict__)). > It's interesting to read the justification for the rejection, among other things: "According to Raymond Hettinger, use of frozendict is low." Then it goes on to provide examples. And of course, the MappingProxy type is used for class dicts, and exposed for other code to use. However, what strikes me is that the list of reasons we don't need an immutable dict is jsu that -- it isn't strictly necessary -- which is not the same as it not being useful. And the MappingProxy is heavier weight and can't be hashed (i.e. used as a key in a dict or put in a set) In the last ten years, we have seen this brought up over and over again -- there really are quite a few use cases. I would love to see PEP 416 reconsidered. (note: it would need a touch of editing to cover the fact that dicts are now ordered) -CHB > > Victor > _______________________________________________ > Python-Dev mailing list -- python-dev@python.org > To unsubscribe send an email to python-dev-le...@python.org > https://mail.python.org/mailman3/lists/python-dev.python.org/ > Message archived at > https://mail.python.org/archives/list/python-dev@python.org/message/IQMBELHLSWSEYQI7BEPTJTYP47BWTBUV/ > Code of Conduct: http://python.org/psf/codeofconduct/ > -- Christopher Barker, PhD (Chris) Python Language Consulting - Teaching - Scientific Software Development - Desktop GUI and Web Development - wxPython, numpy, scipy, Cython
_______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/ZHA54FFDVILXGBBP2TVTA2JEYTO3LJCW/ Code of Conduct: http://python.org/psf/codeofconduct/