WASM and Python #1935
Replies: 3 comments 8 replies
-
Thanks for kicking off the discussion! I am woefully lacking in knowledge about how Python is used on the web (with wasm) at the moment, so you'll have to bear with me while I ask silly questions. Hopefully together we can figure out what the missing pieces (if any) are.
How do you plan this to be used with wasm? Is it going into an executable program you control? Are you hosting a Python playground for users to try out your package on the web? Or do you want to ship it as a package for others to use your bundle, like we would do fornormal Python packages distributed via PyPI?
Afaik we should build correctly for the |
Beta Was this translation helpful? Give feedback.
-
Oh I see! I'm not aware of any packages which allow creating bindings for Wasm and Python in a single framework. You could use I tend to find that the language interfaces do have some code specific to the target languages, so some code "duplication" can be a good thing anyway to make the bindings more idiomatic. Not saying that a package that solves both with minimal duplication wouldn't be cool! |
Beta Was this translation helpful? Give feedback.
-
There is https://github.com/ethanhs/python-wasm now. |
Beta Was this translation helpful? Give feedback.
-
I just finished successfully building a rust/pyo3 python package with a bunch of custom exported structs, and realized that it would actually be very beneficial to also export something with wasm for use on the web. Currently, the package is structured like this:
A main struct/class that is instantiated with an xml-formatted string and a number of additional optional parameters (e.g.
Option<Vec<CustomEnum>>
orOption<CustomStruct>
). It also has a methodmethod1
that accepts similar types of arguments. That looks something like this:Each of the enums enclose a variety of structs (e.g. CustomStruct1, CustomStruct2, .... CustomStruct14). I suppose I could enclose those in a Box as well, but I ended up using enums instead for the time being.
So, in the
lib.rs file
, I construct the module by adding all those different structs as classes, including the ones I enclose in the enums.Talking on the gitter channel, it seems like it might be possible to handle this in part with some support for WASM that pyo3 has, but I wasn't sure how to make use of that, and what changes I may have to make. Any help/advice would be appreciated, and let me know if you need any more info!
Beta Was this translation helpful? Give feedback.
All reactions