gala icon indicating copy to clipboard operation
gala copied to clipboard

Can ImmutableDict be replaced with MappingProxyType?

Open nstarman opened this issue 3 years ago • 2 comments

The latter is built into python.

nstarman avatar Oct 13 '22 16:10 nstarman

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?

adrn avatar Oct 17 '22 16:10 adrn

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.

nstarman avatar Oct 17 '22 19:10 nstarman