# pydantic/monty · xMas Performance Challenge by CodSpeed

> A secure Python sandbox, written in Rust, for code written by AI.

A Python interpreter in Rust that runs code from AI agents safely, without a container.

AI agents write code and run it at many steps of a task, so they run it often. A Monty sandbox starts in under 1 ms, against about 1.5 s for a container service, which leaves the interpreter's own speed as the time an agent waits: every speedup here shortens every step.

## Facts

- Repository: https://github.com/pydantic/monty
- Language: Rust, with Python and JS bindings
- License: MIT
- Open: Tue Dec 1 to Dec 31, 23:59 UTC
- Measured: Walltime, on [CodSpeed Macro Runners Gen 2](https://codspeed.io/docs/features/macro-runners#amd-ryzen-9950x-x86_64)
- Frozen at upstream commit a96e6bd

## Start

```sh
curl -fsSL https://xmas.codspeed.io/install.sh | sh
codspeed-xmas init pydantic/monty
```

Windows: `powershell -ExecutionPolicy Bypass -c "irm https://xmas.codspeed.io/install.ps1 | iex"`. More in the [CLI README](https://github.com/CodSpeedHQ/codspeed/blob/main/crates/codspeed-xmas/README.md).

## What to make faster

- `crates/monty-bench/benches/main.rs` (main): Interpreter speed: runs 35 Python scripts inside Monty (data processing with JSON, CSV, regex and strings, a few pyperformance programs, file walking), plus parsing, the REPL and session save and restore.
- `crates/monty-bench/benches/decode.rs` (decode): Decoding speed of the frames a worker sends back to the host: 4 MiB of row dicts and 4 MiB of shared nested lists.
- `crates/monty-bench/benches/pool.rs` (pool): Cost of running code in an isolated worker process: spawning a worker, checking out a session, and round-tripping external calls and rows over the wire.

## Rules

- Submit only with the CodSpeed CLI. Don't open issues or pull requests on pydantic/monty.
- AI tools are allowed and encouraged.
- monty's own tests have to pass. CodSpeed runs the frozen benchmarks on every submission; your speedup sets your rank.
- When submissions close, entries that break tests, only game a benchmark or aren't of mergeable quality are set aside. In early January the monty maintainers choose what they want merged upstream.
- By submitting, you license your changes under monty's own license (MIT).
- Full rules: [official rules (PDF)](https://xmas.codspeed.io/official-rules.pdf)

## Prizes

- The top 3 entries the monty maintainers choose split monty's share of the $15,000 project pool (50% / 30% / 20%), paid in cash.
- $20,000 in total prizes across the challenge: https://xmas.codspeed.io/#prizes

## Maintainers

- Samuel Colvin ([@samuelcolvin](https://github.com/samuelcolvin))
- David Hewitt ([@davidhewitt](https://github.com/davidhewitt))

## Links

- Page: https://xmas.codspeed.io/projects/monty
- Discord: https://discord.gg/5kU3aV2sRN
- All projects: https://xmas.codspeed.io/llms.txt
