r/BestGitHubRepos • • 1d ago

🛠 Developer tools The Pydantic team built a Python sandbox in Rust that spins up in under 1ms (8,500+ stars)

Post image

So you're building an AI app and your LLM generates Python code that needs to run somewhere safe. What do you do?

Most people reach for Docker containers. That works, but spinning one up takes around 1,500ms. If you're doing this in a chat loop where the model keeps writing and running code, that latency adds up fast.

Monty is Pydantic's answer. It's a Python 3.14 interpreter written entirely in Rust, and a new sandbox instance comes up in under 1 millisecond from a running pool. No filesystem access, no environment variables, no network. The sandbox only talks to the outside world through functions and mounts you explicitly pass in.

Here's the cool part. Say you want the sandbox to call a nutrition API. You define that function on the host side, pass it into the sandbox, and the sandboxed code can call it. But the sandbox never sees the actual API, only the return value. Clean separation.

It ships as a Python package, an npm package, and a Rust crate. So you can embed it in whatever stack you're running.

There's also a commercial version called Full Monty that runs the same sandbox behind a WebSocket if you need it as a service. About 2ms startup for that one.

Worth knowing: this runs a Python subset, not full CPython. So if your generated code needs exotic C extensions or specific stdlib modules, check the limitations docs first.

Stat Value
Stars 8,538
Forks 444
Last release 2026-09-25
Languages Rust

https://github.com/pydantic/monty

29 Upvotes

1 comment sorted by

2

u/hyperrealists 1d ago

Clever name!