← all repositories
pydantic/monty

A Python interpreter so small it fits inside your LLM's ego

Pydantic's Monty runs agent-generated Python in single-digit microseconds without a container in sight.

7.9k stars Rust Coding Assistants
monty
Velocity · 7d
+6.6
★ / day
Trend
steady
star history

What it does

Monty is a Rust-built Python interpreter designed for one increasingly common headache: safely executing code that an LLM just hallucinated into your chat window. It starts up in under a microsecond and runs without any dependency on CPython, containers, or sandboxes. The host filesystem, network, and environment variables are completely unreachable unless you explicitly wire them in as external function calls.

The interesting bit

The killer feature isn’t speed—it’s pausability. Monty can snapshot its entire interpreter state to bytes whenever it hits an external function call, then resume later, potentially in a different process or after a database round-trip. That makes it practical to let an agent write a multi-step Python script that calls your tools, without keeping a live process around between steps.

Key highlights

  • Startup time is sub-microsecond; runtime performance is roughly in CPython’s ballpark (±5×, per the README’s own estimate)
  • Ships with ty for modern Python typechecking in a single binary
  • Resource limits are first-class: memory, allocations, stack depth, and execution time can all be capped
  • Bindings exist for Python, Rust, JavaScript, plus community bindings for Go and Dart/Flutter
  • Will soon power codemode in Pydantic AI, following the pattern Anthropic and Cloudflare have been advocating

Caveats

  • Explicitly experimental and “not ready for the prime time”
  • No classes, no match statements, no third-party libraries, and only a thin slice of the standard library (sys, os, typing, asyncio, re, datetime, json, dataclasses “soon”)
  • The authors are upfront that this is intentionally limited: if your use case isn’t “run code written by agents,” you’re holding it wrong

Verdict

Worth watching if you’re building agent frameworks and tired of Docker’s cold-start tax. Not a replacement for CPython, Pyodide, or WASM for general workloads—this is a specialized tool for a specialized job, and it knows it.

Frequently asked

What is pydantic/monty?
Pydantic's Monty runs agent-generated Python in single-digit microseconds without a container in sight.
Is monty open source?
Yes — pydantic/monty is open source, released under the MIT license.
What language is monty written in?
pydantic/monty is primarily written in Rust.
How popular is monty?
pydantic/monty has 7.9k stars on GitHub and is currently holding steady.
Where can I find monty?
pydantic/monty is on GitHub at https://github.com/pydantic/monty.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.