Skip to content

Conversation

@brandtbucher
Copy link
Member

@brandtbucher brandtbucher commented Jul 23, 2021

This keeps us from breaking encapsulation and (in 3.11) possibly segfaulting.

Should this be backported to 3.9 as a bugfix? If so, the docs should be updated to read .. versionchanged:: 3.9.7.

https://bugs.python.org/issue43838

@brandtbucher brandtbucher added the needs backport to 3.10 only security fixes label Jul 23, 2021
@brandtbucher brandtbucher changed the title bpo-43838: Use a copy to delegate type.MappingProxyType operators bpo-43838: Use a copy to delegate types.MappingProxyType operators Jul 23, 2021
@brandtbucher
Copy link
Member Author

Closing and reopening to trigger CI.

@ambv
Copy link
Contributor

ambv commented Jul 23, 2021

Note @ncoghlan's comment on the issue:

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.

@ncoghlan
Copy link
Contributor

ncoghlan commented Aug 1, 2021

@brandtbucher pointed out on the ticket that my alternative proposal was based on a flawed assumption: that the dict method implementations would play well with others even without the coercion dance. They don't, they rely on the coercion dance and the fact that every other mapping type plays well with builtin dicts.

So it's either make a copy of the underlying object and expose that instead, or reimplement generic union and comparison operations that work for any mapping type.

@github-actions
Copy link

github-actions bot commented Sep 1, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting core review needs backport to 3.10 only security fixes stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants