Skip to main content

Documentation Index

Fetch the complete documentation index at: https://edgepython.com/llms.txt

Use this file to discover all available pages before exploring further.

Sandbox limits

Edge Python supports two limit profiles. Pick one when constructing the VM (VM::with_limits in Rust, --sandbox flag from the CLI).
Limitnone() (default)sandbox()What hitting it raises
Max call depth1,000256RecursionError
Max operationsunbounded100,000,000RuntimeError
Max heap bytes10,000,000100,000MemoryError

Triggering limits

# Recursion depth
def loop(n):
    return loop(n + 1)

try:
    loop(0)
except RecursionError:
    print("hit max depth")
Output
hit max depth
# Heap quota — a tight loop allocating new objects
try:
    xs = []
    while True:
        xs = xs + [0] * 1000
except MemoryError:
    print("hit heap limit")

Source size

The source file must be under 10 MiB. Larger inputs are rejected at lex time.

Token limits

LimitValue
Max indent depth100
Max f-string depth200
Max expression depth200
Max instructions per chunk65,535
These prevent pathological asymmetric DoS — a small input that produces an exponentially large parse tree or instruction stream.

Error types

Compile-time

Reported as Diagnostic { line, col, end, msg }. Caught before any code runs.
DiagnosticCause
expected X, got 'Y'Unexpected token
'break' outside loopMisplaced control keyword
'continue' outside loopMisplaced control keyword
default 'except:' must be lastBare except not at end
expression too deeply nestedPast MAX_EXPR_DEPTH
program too large: exceeded maximum instruction limitPast MAX_INSTRUCTIONS

Runtime

Raised as VmErr. Most are catchable with try / except.
VariantClass nameWhen
TypeTypeErrorWrong operand type
ValueValueErrorRight type, invalid value
NameNameErrorUndefined name
ZeroDivZeroDivisionErrorDivision or modulo by zero
CallDepthRecursionErrorPast max_calls
HeapMemoryErrorPast heap limit
BudgetRuntimeErrorPast op limit
RuntimeRuntimeErrorInternal invariant or unsupported
RaisedExceptionUser raise X with non-builtin X

Catching errors

def safe(f, x):
    try:
        return f(x)
    except TypeError:
        return "type"
    except ValueError:
        return "value"
    except ZeroDivisionError:
        return "zero"
    except:
        return "other"

print(safe(lambda x: 1 / x, 0))
print(safe(lambda x: int(x), "abc"))
print(safe(lambda x: len(x), 42))
Output
zero
value
type

Unsupported features at runtime

These parse but raise RuntimeError when executed.
# Classes
try:
    class Foo:
        pass
except RuntimeError as e:
    print("class:", e)
# Imports
try:
    import os
except RuntimeError as e:
    print("import:", e)
These exist for syntactic compatibility — your code can be lifted from CPython without parsing failing — but the VM rejects them when reached. If you need a value-oriented record, use a dict or a tuple. If you need code reuse, use higher-order functions.

Determinism

For a given source program and input, Edge Python produces the same output across runs and across architectures (x86_64, aarch64, wasm32). There is no time, no randomness, no thread scheduling, no OS interaction. The only source of nondeterminism is the heap pool’s slot reuse, which is observable through id(x) only — never through ==, repr, or any other operation.