bpo-40273: Reversible mappingproxy by ZackerySpytz · Pull Request #19513 · python/cpython · GitHub
Skip to content

bpo-40273: Reversible mappingproxy - #19513

Merged
rhettinger merged 3 commits into
python:masterfrom
ZackerySpytz:bpo-40273-mappingproxy-reversible
May 8, 2020
Merged

rhettinger merged 3 commits into
python:masterfrom
ZackerySpytz:bpo-40273-mappingproxy-reversible

Conversation

@ZackerySpytz

@ZackerySpytz ZackerySpytz commented Apr 14, 2020

Copy link
Copy Markdown
Contributor

@ZackerySpytz

Copy link
Copy Markdown
Contributor Author

@brandtbucher brandtbucher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! One tiny suggestion for the test:

Comment thread Lib/test/test_types.py Outdated
Comment on lines +774 to +775
del d['foo']
r = reversed(self.mappingproxy(d))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think creating the proxy before deleting the element makes sure that this is indeed an updating view:

Suggested change
del d['foo']
r = reversed(self.mappingproxy(d))
mp = self.mappingproxy(d)
del d['foo']
r = reversed(mp)

@brandtbucher brandtbucher added the type-feature A feature request or enhancement label Apr 14, 2020
@brandtbucher

Copy link
Copy Markdown
Member

This should probably also get docs, similar to the ones for dict:

.. describe:: reversed(proxy)

   Return a reversed iterator over the keys of the underlying mapping.

   .. versionadded:: 3.9

@rhettinger rhettinger Apr 14, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a versionchanged entry in the main docs as well.

@brandtbucher brandtbucher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@brandtbucher
brandtbucher requested a review from rhettinger May 6, 2020 17:34
@rhettinger
rhettinger merged commit 02fa0ea into python:master May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants