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
bpo-40273: Reversible mappingproxy #19513
Conversation
The tests are based on |
There was a problem hiding this 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:
Lib/test/test_types.py
Outdated
del d['foo'] | ||
r = reversed(self.mappingproxy(d)) |
There was a problem hiding this comment.
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:
del d['foo'] | |
r = reversed(self.mappingproxy(d)) | |
mp = self.mappingproxy(d) | |
del d['foo'] | |
r = reversed(mp) |
This should probably also get docs, similar to the ones for .. 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks!
https://bugs.python.org/issue40273