Brandt Bucher <[email protected]> added the comment:
I believe that delegating to the actual underlying mapping without exposing it
is a bit of a lost cause, since for some type m we still need these to work:
>>> types.MappingProxyType(m({"a": 0)) | types.MappingProxyType(m({"b": 1}))
m({'a': 0, 'b': 1})
>>> types.MappingProxyType(m({"a": 0)) == types.MappingProxyType(m({"a": 0}))
True
(Note that because both sides are proxies, it's impossible for any resolution
to happen without m explicitly knowing how to handle them unless both mappings
are unwrapped simultaneously.)
Instead, the attached PR delegates to a *copy* of the underlying mapping for
these operations instead. I think this is the easiest way to approximate the
current behavior while maintaining proper encapsulation.
----------
stage: patch review ->
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue43838>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com