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 macro for importing a type (ala import_exception) #3428

Open
alex opened this issue Sep 1, 2023 · 2 comments
Open

Add macro for importing a type (ala import_exception) #3428

alex opened this issue Sep 1, 2023 · 2 comments

Comments

@alex
Copy link
Contributor

alex commented Sep 1, 2023

Currently import_exception makes it easy to import and use an exception type defined in Python from Rust. It'd be useful to have a generalized version of this that gave you a type.

Right now it can be accomplished by writing imperative py.import().getattr() statements, but these are quite verbose.

It'd be a big ergonomics win to have a builtin way to do this.

@davidhewitt
Copy link
Member

I drafted such a thing a long time ago in https://github.com/davidhewitt/pyo3-pytypes - it's horribly broken though. We could try to revive it.

I'd prefer not put an API in pyo3 main repo until we figure out how it interacts with subinterpreters. #576 has details on what kinds of internals are a problem.

@alex
Copy link
Contributor Author

alex commented Sep 2, 2023

Hmmm, ok. Sub-interpreters feels like a very deep mess.

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

2 participants