I notice when I create class in python2 it stores attributes in dict_proxy object:
>>> class A(object):
... pass
>>> A.__dict__
dict_proxy({....})
But in python3 __dict__ returns mappingproxy:
>>> class A(object):
... pass
>>> A.__dict__
mappingproxy({....})
Is there any difference between two of them?
There is no real difference, it just got renamed.
When it was proposed to expose the type in the typing module in issue #14386, the object was renamed too:
I'd like to bikeshed a little on the name. I think it should be MappingProxy. (We don't use "view" much but the place where we do use it, for keys/values/items views, is very different I think. Also collections.abc already defines MappingView as the base class for KeysView and friends.)
and
Anyway, you are not the first one who remarks that we already use "view" to define something else, so I wrote a new patch to use the "mappingproxy" name (exposed as types.MappingProxyType).
The change made it into Python 3.3, so in Python 3.2 you'll still see the old name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With