Author Alex Hayes
Recipients Alex Hayes, rhettinger
Date 2017-08-23.00:29:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Some background. I'm not actually trying to pickle MappingProxyType, I'm using the schematics [1] library and recently it broke support for pickle [2] and the cause of that is because they are using MappingProxyType [3] internally (when they used to use dict).

The Python docs on MappingProxyType [4] provides an appropriate level of API documentation but what it doesn't cover is when you should or should not use MappingProxyType (understandably, it's most likely a complex answer). However, I imagine that it's being used in schematics because at the bottom of the Python dict documentation [5] it states;

> See also types.MappingProxyType can be used to create a read-only view of a dict.

To answer the question "What would be the point of pickling a MappingProxy?" I would probably have to ask, what is the intended use of MappingProxyType?

If one was unfamiliar with the way in which pickle and MappingProxyType works I imagine they would think there would be no reason why a "read-only view of a dict" can't be pickled.

So I guess my questions now are;

1. Should types.MappingProxyType be pickleable?
2. Should there be some documentation about the intended use of MappingProxyType?

I imagine the answer to the first question is "no" given how `__setstate__` works.


Date User Action Args
2017-08-23 00:29:33Alex Hayessetrecipients: + Alex Hayes, rhettinger
2017-08-23 00:29:33Alex Hayessetmessageid: <>
2017-08-23 00:29:33Alex Hayeslinkissue31209 messages
2017-08-23 00:29:31Alex Hayescreate