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

[Feature Request] Optimize PythonObject.__contains__ with a CPython API function #3806

Open
1 task done
rd4com opened this issue Nov 25, 2024 · 0 comments
Open
1 task done
Labels
enhancement New feature or request help wanted Extra attention is needed mojo-repo Tag all issues with this label

Comments

@rd4com
Copy link
Contributor

rd4com commented Nov 25, 2024

Review Mojo's priorities

What is your request?

Hello, we have PythonObject.__contains__ working: #3101

It would be nice if somebody could optimize it with the corresponding CPython API 👍

Here is the current implementation:

if cpython.PyObject_HasAttrString(self.py_object, "__contains__"):
    return self._call_single_arg_method("__contains__", rhs).__bool__()
for v in self:
    if v == rhs:
        return True
return False

What is your motivation for this change?

To speedup the PythonObject.__contains__,
and by using the CPython functions,
it would not have to change a lot later 👍

Any other details?

Ping to @JoeLoser ,
(suggested the feature request in a PR 👍 )

@rd4com rd4com added enhancement New feature or request mojo-repo Tag all issues with this label labels Nov 25, 2024
@JoeLoser JoeLoser added the help wanted Extra attention is needed label Nov 26, 2024 — with Linear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

2 participants