Add support for mappingproxy? (standard library read-only dict)
Quoting Python docs for vars:
Objects such as modules and instances have an updateable
__dict__attribute; however, other objects may have write restrictions on their__dict__attributes (for example, classes use atypes.MappingProxyTypeto prevent direct dictionary updates).
There's pyo3::ffi::PyDictProxy_Type and pyo3::ffi::PyDictProxy_New but they are currently unused.
It's almost a copy of PyDict, with only these methods present: copy, get, items, keys, values.
This has come up while implementing structured dtypes in rust-numpy, where dtype.fields is a read-only mappingproxy dict. It could be worked around via PyAny, but I figured maybe I should raise it here in case there's any interest.
Yep I think having this is very reasonable. Anyone is welcome to pick this up - should be a case of copying the relevant parts of the PyDict implementation to create a new type. Perhaps the hardest bit is what to call it - the C API is PyDictProxy, but I wonder if PyMappingProxy is better to reflect it's name from Python?