Ideas for code reuse across Python classes when targeting wasm32-unknown-emscripten
#3628
Unanswered
kylebarron
asked this question in
Questions
Replies: 1 comment
-
I've thought about this myself sometimes. The only option I think right now would be for you to add your own proc macro which you add before Ultimately my preferred solution long-term would be for "distributed slice" support like what's in the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm interested in using pyo3 to create Rust-based Python packages that can run in Pyodide in WebAssembly. I have various classes and would like to share methods between them in a way that works when compiling to the
wasm32-unknown-emscripten
target.From a previous issue I created, it appears that
multiple-pymethods
does not and cannot support thewasm32-unknown-emscripten
target. I also tried expanding a macro inside animpl
block and gotAs a more explicit example, in my project I have various classes
PointArray
,LineStringArray
,PolygonArray
,MultiPointArray
,MultiLineStringArray
, andMultiPolygonArray
for storing different types of geospatial data. Each of these will largely have the same geospatial operations, sayarea
. Right now, the prototype usesmultiple-pymethods
and is implemented like so:But this won't work when compiling to WebAssembly because it has multiple pymethods.
Likewise I wanted to see if macros could possibly work, but a simple test for that failed:
So I wanted to ask: does anyone have any ideas for sharing code among classes that can be compiled to
wasm32-unknown-emscripten
?Beta Was this translation helpful? Give feedback.
All reactions