limitations/resource_limits.md
Monty enforces hard limits on memory, time, allocations, and recursion to
keep untrusted code bounded. When a limit is exceeded, execution
terminates with a ResourceError (visible to the host, not catchable
inside the sandbox).
'x' * n), padding (str.ljust,
str.center, str.zfill, bytes.ljust, …), and f-string formatting
(both dynamic width f"{v:>{w}}" and dynamic precision on float
formats f"{v:.{p}f}" / e / %). The pre-check threshold is 100 KB —
anything that would estimate above that is rejected with ResourceError
rather than attempting the allocation.bigint.pow(base, exp) estimates result size as bits(base) * exp with
a 4× safety multiplier to cover repeated-squaring intermediate values.pow(base, exp) / base ** exp with an exponent larger than u32::MAX
(≈ 4.3 × 10⁹) raises OverflowError: "exponent too large".pow(base, exp, mod) requires all integer arguments and rejects negative
exponents (ValueError).int(str) for very long decimal strings is rejected before the O(n²)
BigInt parse runs; the cut-off matches CPython's sys.int_info.str_digits_check_threshold.RecursionError.sys.getrecursionlimit() / setrecursionlimit() — the
limit cannot be changed by sandboxed code.await boundary is treated
as one frame, so await-chains do not amplify depth.ResourceError.json.loads rejects input nested deeper than 200 levels with
json.JSONDecodeError (independent of the Python recursion limit).When a resource limit fires, no guarantees are made about heap state or reference counts. The host should discard the VM rather than try to recover and continue running code in it.