On Tue, 1 Dec 2020 at 13:16, Paul Sokolovsky <pmis...@gmail.com> wrote: > If you want immutable dict you [know whom to thank for the lack of it - > stroked thru] can use types.MappingProxyType, as was explained (it's > all about PEP603). > > The last case with immutable dict also shows that proliferation of both > mutable and immutable type counterparts doesn't scale. What we need is > some generic types.roproxy (yes, all lower-case, to emphasize its > fundementalness) which can be applied to any object, and will filter > out __setitem__ and __setattr__ (and del counterparts, and custom list > of mutator methods, you get an idea).
Is it not more simple for the moment to have it only as a sort of warning for the developer? I mean, if the object is mutated, a warning is raised at runtime. If the object is rebound, a SyntaxError is emitted. I suppose that this is possible for dicts, since they have an internal attribute ma_version_tag, that is increased every time the dict mutates. Classes have __dict__. Don't know for the other builtin types. Speed optimizations could be done later, if they are possible. _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4GIKATDJM6BOJO3S5WZXP27RYMXGU4I3/ Code of Conduct: http://python.org/psf/codeofconduct/