-
Notifications
You must be signed in to change notification settings - Fork 0
3 Possible Solutions
The following solutions are discussed in more detail below.
- Implement Python in Javascript / TypeScript
- Transpile Existing Python Implementation to JS/TS
- Compile Existing Python Implementation to Webassembly
- Transpile Python Modules to JS/TS
- Compile Python Modules to WASM
- Use a Python-like Language
- Platform Emulation
- Interact With a Python "Server" Over a Socket/stdio
The following "possible" solutions are not options for a variety of reasons, including cross-compatibility issues.
- Ship native CPython
- Support Python Natively in the Browser
- CPython as a Node "Addon"
Either do this from scratch, build on an existing project, or use an existing project.
See: Batavia
...
See: ???
See: Pyodide, MicroPython
Two approaches:
- pre-convert & ship JS
- ship (or GET) .py & convert in browser
See: Brython, Transcrypt
- C -> WASM: emscripten
- Python -> C: Nuitka
- Python -> C++: ShedSkin
- leverage Cython?
See: ???
See: RapydScript
See: MicroPython
- every web app ever
- subprocesses
See: ???
Reason Rejected: not cross-platform; not supported in browser
Reason Rejected: not feasible
Essentially, embed CPython in the browser binary. This is out of most of our hands. Realistically, it's not going to happen.
The easiest would probably be interacting with Python over the network/stdio. However, it's probably the least efficient.
Reason Rejected: not cross-platform
In the Node.js world there's also the option of using an "addon" to expose Python. CPython has a rich embedding story. A Node module would be written in C which embeds the CPython runtime and wraps select parts in the format that Node understands. That would be compiled to a platform-specific shared object file from which Node could import the exported wrappers.