Skip to content

bpo-43838: Use a copy to delegate types.MappingProxyType operators - #27300

Closed
brandtbucher wants to merge 5 commits into
python:mainfrom
brandtbucher:mappingproxy-delegation
Closed

brandtbucher wants to merge 5 commits into
python:mainfrom
brandtbucher:mappingproxy-delegation

Conversation

@brandtbucher

@brandtbucher brandtbucher commented Jul 23, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

Closing and reopening to trigger CI.

@ambv

ambv commented Jul 23, 2021

Copy link
Copy Markdown
Contributor

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

ncoghlan commented Aug 1, 2021

Copy link
Copy Markdown
Contributor

@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

github-actions Bot commented Sep 1, 2021

Copy link
Copy Markdown

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