gala
gala copied to clipboard
Can ImmutableDict be replaced with MappingProxyType?
The latter is built into python.
In reading a bit more about MappingProxyType, I came across this discussion: https://stackoverflow.com/questions/41795116/difference-between-mappingproxytype-and-pep-416-frozendict
Given that ImmutableDict is pretty lightweight to maintain, I don't know that it's worth it. If you have a stronger opinion can you say more? Have you been using MappingProxyType yourself?
No strong opinion. Just minimizing private API. I use MappingProxyType anywhere I want to make an immutable dict linked to a dict I don't want changed. I find it particularly useful as the output of a property. It can't be pickled, but that's really a plus, because it's tied to the original dict.