Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can ImmutableDict be replaced with MappingProxyType? #308

Open
nstarman opened this issue Oct 13, 2022 · 2 comments
Open

Can ImmutableDict be replaced with MappingProxyType? #308

nstarman opened this issue Oct 13, 2022 · 2 comments

Comments

@nstarman
Copy link
Contributor

The latter is built into python.

@adrn
Copy link
Owner

adrn commented Oct 17, 2022

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?

@nstarman
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants