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 in operator method to PyAny #2107

Closed
davidhewitt opened this issue Jan 17, 2022 · 2 comments · Fixed by #2115
Closed

Add in operator method to PyAny #2107

davidhewitt opened this issue Jan 17, 2022 · 2 comments · Fixed by #2115

Comments

@davidhewitt
Copy link
Member

We don't have a method for x in foo on PyAny.

We have PySequence::contains - probably this just wants to be copied as PyAny::contains, with some tests to check this does behave like Python's in operator.

As per #1844 (comment)

@aganders3
Copy link
Contributor

I'm interested to take this on!

For design purposes, the in keyword means two things in Python. This was kind of covered in the linked PR where there was discussion of contains_key but I think it was kept out. The idea here then is to use PySequence_Contains for PyAny::contains, right? Is there any need to do a check first?

@davidhewitt
Copy link
Member Author

Great, thank you!

The idea here then is to use PySequence_Contains for PyAny::contains, right? Is there any need to do a check first?

Yes, I think probably calling PySequence_Contains is all the implementation needs. A few tests should be able to confirm that it behaves as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants