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

Trait_bounds example should not need to acquire GIL #1042

Open
davidhewitt opened this issue Jul 15, 2020 · 0 comments
Open

Trait_bounds example should not need to acquire GIL #1042

davidhewitt opened this issue Jul 15, 2020 · 0 comments

Comments

@davidhewitt
Copy link
Member

davidhewitt commented Jul 15, 2020

In the trait_bounds example, the trait signature impl Model for UserModel has no way to pass a Python into the trait methods. The idea for this example is to show how to wrap a Rust trait which doesn't know anything about Python, so I don't think changing the trait definition is a solution either.

Originally posted by @davidhewitt in #1037

It would be nice to come up with a pattern here which allows #[pyclass] structs which work like in this example to implement Rust traits without needing to acquire GIL.

The trait doesn't even have to be a complicated one like in the trait_bounds example. For some #[pyclass] structs even their Display implementation may need to acquire the GIL.

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

No branches or pull requests

1 participant