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

Add Mapping::contains #2133

Merged
merged 6 commits into from
Feb 6, 2022
Merged

Conversation

Gobot1234
Copy link
Contributor

@Gobot1234 Gobot1234 commented Jan 29, 2022

Pretty self explainitory.

This function like the collections.abc.Mapping equivalent cannot fail (https://github.com/python/cpython/blob/8fb36494501aad5b0c1d34311c9743c60bb9926c/Lib/_collections_abc.py#L823-L829).

@davidhewitt
Copy link
Member

The analogy with collections.abc.Mapping is reasonable, however it makes me uncomfortable too. This isn't equivalent to the in operator; we just merged #2115 which added PyAny::contains. Given that, do we really need to add this too?

In particular, the thing I don't like about PyMapping_HasKey (and particular wrapping it in a method called contains) is that it looks like it should call __contains__, but it does not.

@Gobot1234
Copy link
Contributor Author

Ok fair enough, what about just making it call PyAny::contains?

@davidhewitt
Copy link
Member

I'd prefer that :)

Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

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

Thanks!

@davidhewitt davidhewitt merged commit b2f9e28 into PyO3:main Feb 6, 2022
@Gobot1234 Gobot1234 deleted the Mapping--contains_key branch February 6, 2022 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants