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 Rust support for type hinting objects #4849

Open
IvanIsCoding opened this issue Jan 10, 2025 · 2 comments
Open

Add Rust support for type hinting objects #4849

IvanIsCoding opened this issue Jan 10, 2025 · 2 comments

Comments

@IvanIsCoding
Copy link
Contributor

In short, I learned recently about Objects for Type Hinting in Qiskit/rustworkx#1345 and they are not available in pyo3-ffi. Those specific types have been part of the Stable ABI since 3.9.

Currently, I can still achieve my goals by importing types.GenericAlias via the Python interpreter but I still think typing objects deserve to be included.

I am willing to contribute the Rust bindings if they are welcome.

@davidhewitt
Copy link
Member

Yep a PR to add these to pyo3-ffi seems straightforward. Going further, a way to define __class_getitem__ that's similar to python might be nice (e.g. by doing it with #[pyclass(generic)] as an option)

@ngoldbaum
Copy link
Contributor

ngoldbaum commented Jan 10, 2025

Yep a PR to add these to pyo3-ffi seems straightforward.

I recently had to touch pyo3-ffi a bunch to add support for free-threaded Python. Please feel free to ping me if you get stuck - although genericaliasobject.h looks pretty straightforward!

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

3 participants