Getting StartedQuickstart

Run it

Edge Python ships as a 170 KB WebAssembly module. Fastest way to try it, the playground, no install, fully client-side.

Open the playground ->

Embed it

Two artifacts:

  1. compiler_lib.wasm (170 KB, lexer, parser, stack VM).
  2. A loader. Browser: the runtime/ package; WASI: your runtime’s import API.

Build yourself:

git clone https://github.com/dylan-sutton-chavez/edge-python
cd edge-python/compiler
cargo wasm # -> target/wasm32-unknown-unknown/release/compiler_lib.wasm

Rust consumers can let cargo fetch the release artifact via DEP_COMPILER_LIB_WASM (see the repo README). No native CLI, compiler_lib.wasm is the artifact and the host owns I/O, network, time, module fetching. Full ABI: What it is, Where it runs.

Drop-in HTML element

In the browser, the runtime’s <edge-python> element runs a .py file declaratively, no JS wiring. With a host library like the DOM (declared in packages.json), the script renders straight into the page:

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <script type="module" src="https://runtime.edgepython.com/js/src/element.js"></script>
</head>
<body>
    <div id="app"></div>
    <edge-python entry="./app/hellp.py" packages="./app/packages.json"></edge-python>
</body>
</html>
// packages.json
{ "host": { "dom": "./dom/src/index.js" } }
# hello.py
from dom import query, set_text
set_text(query("#app"), "Hello from Python")

dom is one of the official host libraries (dom, network, storage and more); standard .wasm packages like json sit alongside them. The packages.json above declares dom explicitly, but the browser runtime also resolves the official packages by bare name with no manifest at all (see Defaults), fetching each lazily on first import. See Official packages for the full catalog, and the runtime README for all <edge-python> attributes and the imports field for .py / .wasm modules.

Your first program

Open the playground and try the SimplePerceptron Rosenblatt implementation or try a Python snippet:

greet = lambda name: f"Hello, {name}!"
 
for who in ["world", "edge", "python"]:
    print(greet(who))
Hello, world!
Hello, edge!
Hello, python!

Language overview

Edge Python is a Python subset with classes, async/await, structural pattern matching, and packages.json imports, compiled to bytecode and run on a sandboxed WebAssembly VM.

# First-class functions
ops = [abs, len, str]
print([f(-3) for f in ops])
 
# Currying with closures
add = lambda x: lambda y: x + y
print(add(3)(4))
 
# Pure functions are template-memoised after two hits with the same arguments (no decorators needed, this is detected by the VM)
def fib(n):
    if n < 2: return n
    return fib(n - 1) + fib(n - 2)
 
print(fib(20))
[3, 2, '-3']
7
6765

Next steps

Scope, paradigm, and what intentionally isn't supported. Operators, literals, and the language surface. Every built-in function with examples and outputs. String, list, and dict methods. Ready-made modules: `json`, `dom`, `network`, `storage` and more.