Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-40273: Reversible mappingproxy #19513

Merged

Conversation

ZackerySpytz
Copy link
Contributor

@ZackerySpytz ZackerySpytz commented Apr 14, 2020

@ZackerySpytz
Copy link
Contributor Author

The tests are based on test_reversed() in test_dict.py.

Copy link
Member

@brandtbucher brandtbucher left a comment

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 on lines 774 to 775
del d['foo']
r = reversed(self.mappingproxy(d))
Copy link
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
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

@@ -0,0 +1 @@
:class:`types.MappingProxyType` is now reversible.
Copy link
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.

Copy link
Member

@brandtbucher brandtbucher left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@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.

None yet

5 participants