Writing Rust code that's fast by asking agents to make the code faster
A developer shows agentic models, including Claude Opus 4.5, can iteratively optimize Rust for 2x-20x speedups.
A developer reports that modern coding agents can iteratively rewrite Rust until benchmarks stop improving, producing large speedups. Using Claude Opus 4.5, and earlier Claude Sonnet 3.5, the author reimplemented UMAP in Rust with PyO3 bindings while forbidding unsafe code. Guardrailed prompts, criterion benchmarks, and libraries such as faer and simsimd yielded roughly 2x to 20x gains depending on the domain. Prompts and benchmark results are included.
- Opus 4.5 iteratively optimized Rust against pass/fail benchmark targets.
- Reported speedups range from about 2x to 20x by domain.
- UMAP was rewritten from scratch with PyO3 and no unsafe code.
- criterion tracked statistically significant gains across data sizes.
- Organizations
- Anthropic
- AI models
- Claude Opus 4.5Claude Sonnet 3.5
From the original article
14 min read at minimaxir.com
In January 2025, I had a fun hypothesis for a blog post : can LLMs write better code if you keep asking them to “write better code”? That was prior to the advent of robust agentic coding, but Claude Sonnet 3. 5 was still able to iteratively improve on algorithmic Python code.
By mooreds · minimaxir.com
A short excerpt; the article and its images belong to the publisher. Summary, key facts and assessment above are AI-written from the article and can be wrong.