You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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](/getting-started/what-it-is#where-it-runs).
14
+
The playground is the fastest path; to put Edge Python in your own page, drop in the `<edge-python>` element below. Building the `.wasm` from source or embedding in Rust/WASI is covered in [Where it runs](/getting-started/what-it-is#where-it-runs).
Copy file name to clipboardExpand all lines: docs/pages/getting-started/what-it-is.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Reads like Python (parses Python syntax). Runs differently, what it executes is
17
17
***Exceptions**: `try` / `except` / `else` / `finally`, named handlers, `raise X from Y` (chain info discarded but `X` is what propagates), and subclass-aware matching (`except Exception` catches `RuntimeError`).
18
18
***Context managers**: `with` and `async with` invoke `__enter__` / `__exit__` on the context-manager value; a truthy return from `__exit__` suppresses the raised exception.
19
19
***Protocol dunders**: operator overloading, indexing, iteration, hashing, and `repr` / `str` / `format` dispatch through user-defined dunders, see [Dunders](/language/dunders) for the full matrix.
20
-
***Numbers**: integers up to `±2^127` (auto-promoted past 47 bits; beyond the cap raises `OverflowError`) and full IEEE-754 floats. No `complex`, `Decimal`, `Fraction`, or arbitrary precision beyond 128 bits.
20
+
***Numbers**: bounded integers (fast inline path, auto-promoting to wide; see [Integer width](/reference/limits-and-errors#integer-width)) and full IEEE-754 floats. No `complex`, `Decimal`, or `Fraction`.
***f-strings**: full grammar, embedded expressions, `{expr=}` self-doc, `!r` / `!s` / `!a` conversions, and format specs covering `s d b o x X f F e E g G n % c` plus fill / align / sign / `#` / `0` / width / `,` / precision.
23
23
***Walrus operator**: `:=` in expressions (Name target only).
@@ -41,9 +41,9 @@ These parse for syntactic compatibility but raise at runtime, or simply don't ex
41
41
42
42
Multi-paradigm sandboxed compiler:
43
43
44
-
-**Smaller binary**, compiler + VM in 170 KB WebAssembly release.
44
+
-**Small binary**, compiler + VM in one WebAssembly release.
45
45
-**Faster interpreter**, no method-resolution overhead; hot opcodes promote to type-specialised fast paths via IC.
46
-
-**Aggressive memoisation**, pure functions auto-cached; most functional code is pure by construction.
46
+
-**Aggressive memoisation**, pure functions auto-cached after two hits ([Functions](/language/functions#generators)); most functional code is pure by construction.
47
47
-**Easier sandboxing**, no protocol dispatch, no stdlib; attack surface is the fixed built-in set.
Copy file name to clipboardExpand all lines: docs/pages/implementation/design.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Classes support single-level inheritance, `super()`, full dunder dispatch, `@pro
17
17
-**Single-pass SSA codegen**: Variables versioned per assignment (`x_1`, `x_2`). Control-flow joins emit `Phi` opcodes resolved at runtime.
18
18
-**Token-threaded dispatch**: `Vec<Instruction>` where each is `(opcode: OpCode, operand: u16)`. Hot loop is a flat `match`; Rust lowers it to a jump table. Not direct threading (computed-goto isn't available in safe Rust).
19
19
-**Per-instruction inline caching**: Each binary op records operand type tags. After `QUICK_THRESH = 4` stable hits the IC stores a typed `FastOp` (`AddInt`, `AddFloat`, `AddStr`, `LtFloat`, `EqStr`, `ModInt`, ...) as a speculative fast path with type-guard deopt.
20
-
-**Template memoisation**: Pure user functions cache `(args) -> result` after `TPL_THRESH = 2` hits, capped at 256 entries per function. Gated on no-kw calls, an outer scope free of impure ops (`StoreItem`, `StoreAttr`, `Raise`, `Yield`, `Global`, `Nonlocal`, `Import`, ...), and byte-stable arguments (mutable containers disqualify). Hashing is an FNV-like fold over raw `Val.0` bits with a value-eq verify.
20
+
-**Template memoisation**: pure user functions cache `(args) -> result` after `TPL_THRESH = 2` hits, capped at 256 entries each. Gated on no-kw calls, byte-stable args (mutable containers disqualify), and an impurity-free body (purity detection in [Syntax](/implementation/syntax#lambda-and-function-bodies)). Hashing is an FNV-like fold over raw `Val.0` bits with a value-eq verify.
21
21
-**NaN-boxed values**: `Val` is a 64-bit union: 47-bit signed ints (inline), IEEE-754 floats (NaNs canonicalised), bools, None, an undef sentinel, and 28-bit heap indices.
22
22
-**Mark-and-sweep GC**: Triggered when `live >= gc_threshold` or `alloc_count >= max(live/4, 4096)`. After each sweep `gc_threshold = max(live * 2, 512)`. Roots: stack, with-stack, yields, event queue, slots and live-slot snapshots, slot templates, globals, every iterator frame's `iter_stack`, opcode-cache constants, active const pools, function templates.
23
23
@@ -77,7 +77,7 @@ Heap is a `Vec<HeapSlot>` arena with a free list (capped 524,288, sorted to pref
77
77
78
78
## Coroutine and context-manager dispatch
79
79
80
-
`async def` and `yield`-bearing `def` both produce `HeapObj::Coroutine`. `run()` drives the scheduler; `sleep`, `gather`, `with_timeout`, `cancel`, `receive`are top-level builtins. No `asyncio` module.
80
+
`async def` and `yield`-bearing `def` both produce `HeapObj::Coroutine`. `run()` drives the scheduler; the other primitives are top-level builtins ([Async](/language/async)).
81
81
82
82
A plain `def` inside a coroutine calling a yielding builtin gets its state (`ip`, slots, stack/iter deltas) snapshotted as a `SyncFrame` pushed on the enclosing Coroutine's `sync_frames` (innermost-last). `resume_coroutine` walks this stack inside-out before re-entering the outer body, so each helper's return value lands at the original `Call` site, otherwise the outer's `resume_ip` would skip past the unfinished helper.
Copy file name to clipboardExpand all lines: docs/pages/implementation/syntax.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -206,7 +206,7 @@ Free variables (non-parameters with no local binding) are looked up in the outer
206
206
207
207
Parameter slots: `Normal`, `Star` (`*args`), `DoubleStar` (`**kwargs`). Lone `*` separator marks following params as keyword-only. Defaults live in `HeapObj::Func.defaults` and apply to the last-N positional slots. Annotations (`x: T`, `-> T`) parse and drain to `chunk.annotations` (tooling-only).
208
208
209
-
`compile_body` checks impurity opcodes (`StoreItem`, `StoreAttr`, `CallPrint`, `CallInput`, `Global`, `Nonlocal`, `Import`, `Raise`, `Yield`, `LoadAttr`) to set `body.is_pure`. Template memoisation caches pure `(args) -> result` after `TPL_THRESH = 2` hits (capped at 256 entries).
209
+
`compile_body` checks impurity opcodes (`StoreItem`, `StoreAttr`, `CallPrint`, `CallInput`, `Global`, `Nonlocal`, `Import`, `Raise`, `Yield`, `LoadAttr`) to set `body.is_pure` — the flag that gates template memoisation ([Design](/implementation/design#concepts)).
Copy file name to clipboardExpand all lines: docs/pages/language/data-types.md
+1-23Lines changed: 1 addition & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,29 +33,7 @@ For runtime membership in a type, use [`isinstance`](/reference/builtins#isinsta
33
33
34
34
## Integer
35
35
36
-
Two-tier. **Inline (fast)**: 47-bit signed in a NaN-boxed `Val`, one ALU op per arithmetic, zero alloc. **LongInt (slow)**: i128 in a heap slot, auto when literal/result exceeds 47-bit. Boundary invisible, same `int` type, same operators. Hard cap ±2¹²⁷; wider -> `OverflowError`. No CPython unbounded ints; no complex (`1j`, `2+3j`).
37
-
38
-
```python
39
-
# Inline range
40
-
print(2**46)
41
-
print(2**46-1)
42
-
43
-
# Auto-promoted to LongInt
44
-
print(2**100)
45
-
46
-
# Past the 128-bit cap
47
-
try:
48
-
print(2**127)
49
-
exceptOverflowError:
50
-
print("overflow")
51
-
```
52
-
53
-
```text Output
54
-
70368744177664
55
-
70368744177663
56
-
1267650600228229401496703205376
57
-
overflow
58
-
```
36
+
One `int` type, transparently two-tier: a fast inline path that auto-promotes to wide integers, capped at ±2¹²⁷ (full mechanics in [Integer width](/reference/limits-and-errors#integer-width)). No CPython unbounded ints; no complex (`1j`, `2+3j`).
Copy file name to clipboardExpand all lines: docs/pages/language/dunders.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -178,13 +178,14 @@ class K:
178
178
def__eq__(self, o):
179
179
returnself.n == o.n
180
180
181
-
print(hash(K(5)))
182
-
print({K(1): 'one'}[K(1)] if K(1).__hash__() == K(1).__hash__() else'unhashable')
181
+
k = K(5)
182
+
print(hash(k))
183
+
print({k: 'found'}[k]) # same instance reference looks up reliably
183
184
```
184
185
185
186
```text Output
186
187
5
187
-
one
188
+
found
188
189
```
189
190
190
191
Built-in dict/set still compare instance keys by identity (`Val` bits); user `__hash__` is returned by `hash()` but doesn't change containment in built-in containers. Use the same instance reference to look up reliably.
0 commit comments