You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be great to have a single #[pyo3] macro like the #[wasm-bindgen] macro in wasm-bindgen. This macro would have the following properties:
It can be attached to functions, classes, impl $struct and impl $protocol for $struct. The macro can decide where it's attached to by using syn::parseinto a syn::Item, matching and delegating to the respective code gen function.
It supports the parameters currently supported (mostly by reusing the existing code)
Method types (static, method, etc.) are automatically detected. The constructor might require a #[pyo3(constructor)] annotation
There is #[pyo3(module)] to replace #[pymodule]. It doesn't need to support #[pyfn] though since we can do freestanding functions now.
Tests for all features. This doesn't need to be as elaborate as wasm-bindgen, but maybe we can come up with something where we feed syn item to functions in pyo3-derive-backend. (Integration tests are also sufficient)
The best was to get started is probably adding a function in pyo3cls/src/lib.rs that dispatches to the existing macros and then expanding upon that. Looking into capybara*s pyo3 wrapper and wasm bindgen's macro frontend should give some additional pointers.
The text was updated successfully, but these errors were encountered:
I have been thinking about this and think it's a good idea. We also implemented attributes like #[name = "foo"] on #[pyclass], but in retrospect I think that might have been a mistake and should have been namespaced as #[pyo3(name = "foo)].
We might want to do a review of how much we can add in a non-breaking fashion already and then consider deprecating old names later.
It would be great to have a single
#[pyo3]
macro like the#[wasm-bindgen]
macro in wasm-bindgen. This macro would have the following properties:impl $struct
andimpl $protocol for $struct
. The macro can decide where it's attached to by usingsyn::parse
into asyn::Item
, matching and delegating to the respective code gen function.#[pyo3(constructor)]
annotation#[pyo3(module)]
to replace#[pymodule]
. It doesn't need to support#[pyfn]
though since we can do freestanding functions now.pyo3-derive-backend
. (Integration tests are also sufficient)The best was to get started is probably adding a function in
pyo3cls/src/lib.rs
that dispatches to the existing macros and then expanding upon that. Looking into capybara*s pyo3 wrapper and wasm bindgen's macro frontend should give some additional pointers.The text was updated successfully, but these errors were encountered: