2 ms·
Python is a whole language + libs, and a .py file is a source code file written for it and using its facilities and libs -- not just an low level executable fil
by coldtea 3y ago
Python is a whole language + libs, and a .py file is a source code file written for it and using its facilities and libs -- not just an low level executable file.
WASM on the other side is binary format for a high level virtual machine.
So, you can't just translate .py into .wasm. You need to either:
(a) load your .py code into a Python ported to wasm that can execute it directly as py code
(b) have a python-aware crosspiler that takes a .py file and creates wasm versions than can then be loaded into a runtime that supports Python semantics. This also needs the Python semantics and libs to be ported to wasm.
Not sure if there's anything done for (b) atm, but for (a) see:
https://pyodide.org/en/stable/ https://pyodide.org/en/stable/