This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients brandtbucher, gvanrossum, ncoghlan, rhettinger, serhiy.storchaka
Date 2021-07-23.15:54:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Delegating operations to the underlying mapping is still OK, all we're wanting to bypass is the operand coercion dances in abstract.c and object.c that may expose the underlying mapping to the *other* operand.

But this won't work if *both* operands are proxies, right? The left wrapped mapping will only ever see itself and the right mappingproxy, and the right operand will only ever see itself and the left mappingproxy. The overwhelmingly common case is where these proxies wrap dicts, and dicts only play nicely with other dicts.

I agree that creating redundant copies isn't optimal; it's just the only way that I see we'd be able to fix this without backward compatibility headaches. The fix is easy to explain to users without needing to get into the nuances of operator dispatch or bloating the code to handle weird edge-cases (trust me, I originally tried coding logic to handle all the different possibilities of subclasses and proxies and such before landing on the copying solution).

With that said, I think that if we decide it's really not worth it to copy here, Serhiy's proposal is probably "good enough". Just return a merged dict for the union operation, and implement mapping equality in a sane, usable way. I just worry that it will break backward-compatibility in subtle ways that are basically impossible to fix (comparing equality of proxied OrderedDicts, for example).
Date User Action Args
2021-07-23 15:54:23brandtbuchersetrecipients: + brandtbucher, gvanrossum, rhettinger, ncoghlan, serhiy.storchaka
2021-07-23 15:54:23brandtbuchersetmessageid: <>
2021-07-23 15:54:23brandtbucherlinkissue43838 messages
2021-07-23 15:54:23brandtbuchercreate