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 ncoghlan
Recipients brandtbucher, gvanrossum, ncoghlan, rhettinger, serhiy.storchaka
Date 2021-07-23.10:59:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627037956.47.0.482685132568.issue43838@roundup.psfhosted.org>
In-reply-to
Content
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.

We don't want to implicitly copy though, as the performance hit can be non-trivial for large mappings, even if the algorithmic complexity doesn't change.

For the `nb_or` slot, it should be correct to retrieve and call `__or__` from the underlying mapping when the left operand is a MappingProxy instance, and `__ror__` when the right operand is a MappingProxy instance (but the left operand is not).

Rich comparison is messier though, since PyObject_RichCompare handles both the operand coercion dance *and* the mapping of the specific comparison operations to their implementation slots.

I don't see a clean solution to that other than defining a new PyObject_DelegateRichCompare helper function for the mapping proxy to use that provides the mapping from specific operands to their implementation slots *without* doing the coercion dance.

However we resolve it, I think it probably won't be worth the risk of backporting the change (this has been the way it currently is for a long time, and it's a "reduce the risk of error" feature rather than any kind of security boundary).
History
Date User Action Args
2021-07-23 10:59:16ncoghlansetrecipients: + ncoghlan, gvanrossum, rhettinger, serhiy.storchaka, brandtbucher
2021-07-23 10:59:16ncoghlansetmessageid: <1627037956.47.0.482685132568.issue43838@roundup.psfhosted.org>
2021-07-23 10:59:16ncoghlanlinkissue43838 messages
2021-07-23 10:59:16ncoghlancreate