Python WASM Nodes
Python can run in WASM through several projects, each with trade-offs.
Approaches
Section titled “Approaches”| Project | Binary Size | Startup | Compatibility |
|---|---|---|---|
| Pyodide | ~10 MB | Slow | Full CPython |
| RustPython | ~2 MB | Fast | Most Python |
| MicroPython | ~300 KB | Fast | Subset |
Expected Template (Pyodide)
Section titled “Expected Template (Pyodide)”import json
def get_node(): """Return the node definition.""" return { "name": "wasm_python_uppercase", "friendly_name": "Uppercase (Python)", "description": "Converts a string to uppercase using Python", "category": "Custom/Text", "icon": "/flow/icons/text.svg", "pins": [ { "name": "exec_in", "friendly_name": "▶", "description": "Trigger execution", "pin_type": "Input", "data_type": "Execution", }, { "name": "exec_out", "friendly_name": "▶", "description": "Continue execution", "pin_type": "Output", "data_type": "Execution", }, { "name": "input", "friendly_name": "Input", "description": "The string to convert", "pin_type": "Input", "data_type": "String", "default_value": "", }, { "name": "output", "friendly_name": "Output", "description": "The uppercase string", "pin_type": "Output", "data_type": "String", }, ], "scores": { "privacy": 0, "security": 0, "performance": 3, # Python is slower "governance": 0, "reliability": 0, "cost": 1, }, }
def run(context: dict) -> dict: """Execute the node logic.""" input_value = context.get("inputs", {}).get("input", "")
# Execute logic output_value = input_value.upper()
return { "outputs": { "output": output_value, }, "error": None, }Why Python in WASM is Challenging
Section titled “Why Python in WASM is Challenging”- Large runtime — CPython interpreter is ~10MB
- Slow startup — Interpreter initialization takes time
- Limited I/O — WASM sandbox restricts file/network access
- Package compatibility — Not all PyPI packages work in WASM
Recommended Alternatives
Section titled “Recommended Alternatives”For most use cases, consider:
| If you need… | Use |
|---|---|
| Fastest execution | Rust |
| Familiar syntax | TypeScript |
| Easy learning curve | Go |
| Python specifically | Wait for Python support |
Current Workaround
Section titled “Current Workaround”You can call Python scripts via the Run Script node in Flow-Like, which executes Python on the host system (not in WASM).
Stay Updated
Section titled “Stay Updated”Python WASM support is on our roadmap. Watch the repository for updates:
📧 [email protected] for enterprise Python node development