-
Notifications
You must be signed in to change notification settings - Fork 782
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
Make writing modules simpler #3268
Comments
Thanks for the proposal! I agree the What do you think about allowing #[pymodule]
mod my_extension() {
#[pyfunction]
fn double(x: usize) -> usize {
x * 2
}
} Every I started working on a draft of this in #2367, however I haven't found the time to continue with this. Help in design or implementation is always welcome. |
It looks great! I'd love to have this, especially in a large project; only having to add a |
Closing in favour of #3900, which tracks the |
Currently, with PyO3, it's quite simple to write functions that Python can use. However, it gets a bit weird when it comes to creating a module.
This is the current example:
You can see that the
double
function looks just like normal Rust, only with an added attribute macro. However, defining themy_extension
module is a bit weirder. The syntax is a bit confusing and hard to write for each function you want to expose to Python.This issue is about how to make it simpler to utilize; ideally, it would be as simple as something like this:
Or something along those lines. This would benefit users of PyO3 greatly, especially when it comes to consistently using it in Python projects.
The text was updated successfully, but these errors were encountered: