Most Rust vs Python debates turn into a cartoon: Rust fans post a Fibonacci micro-benchmark showing Rust is 50× faster, and Python fans reply that they shipped the feature before Rust finished compiling.
Both arguments miss how real production systems actually fail. Almost no web API spends its day computing Fibonacci numbers—it spends its day waiting on PostgreSQL, parsing untrusted JSON, streaming HTTP/SSE responses, enforcing auth limits, and surviving messy deploys on a modest server.
In this workspace, we use Rust for all our always-on services, runtimes, and durable workers (Colophon CMS, Durable Runner, Service Monitor, MiniBTC, jsrt) and Python for data scripts, SEO/Ahrefs automation, image tooling, and quick prototypes. Here is where each language genuinely wins—and where picking the wrong one costs you weeks.
Quick decision table
| Dimension | Python (FastAPI / scripts / ML) | Rust (Axum / Tokio / CLI / workers) |
|---|---|---|
| First-day shipping speed | Fastest — minutes from idea to working prototype | Slower upfront; types, lifetimes, and error envelopes take discipline |
| ML & data ecosystem | Unmatched — PyTorch, NumPy, pandas, eval notebooks, every AI SDK lands here first | Growing (candle, ort), but thin compared to Python for model training |
| Memory footprint (idle & under load) | Higher — multiple Uvicorn/Gunicorn workers to bypass the GIL add up fast on a small VPS | Tiny — one binary often runs comfortably in 15–50 MB RAM with real multi-core async |
| Tail latency & concurrency | Good for I/O-bound CRUD; CPU spikes or GC pauses hurt p99 under load | Rock-solid p99 — zero GC pauses, predictable memory and backpressure |
| Packaging & deployment | Virtualenvs, wheel native builds, Python version drift, larger Docker images | One static binary — drop into systemd or a tiny distroless container |
| Refactoring at 50k+ lines | Requires strict mypy/pyright + heavy test discipline to catch silent None/type bugs | Compiler refuses whole classes of null, race, and unhandled-error bugs before tests even run |
Where Python wins cleanly (don’t fight it)
- AI/ML experimentation, training, and data analysis: Every paper, quantization tool, fine-tuning script, and evaluation notebook ships in Python first. Fighting that ecosystem to prove a point wastes months.
- Glue scripts and internal automation: Fetching APIs, transforming CSVs, generating reports, or automating one-off ops tasks takes 40 lines of readable Python and zero compile wait.
- Early-stage CRUD APIs where product-market fit is still unknown: If your startup’s schema changes three times a week and you handle 20 requests per second, FastAPI + Pydantic + Postgres lets a small team iterate fast. (And because Pydantic v2’s core is written in Rust, JSON validation is already fast.)
Where Rust wins cleanly (why we chose it for our core systems)
- Always-on infrastructure & durable workers: Background job runners, uptime monitors, reverse proxies, MCP gateways, and ledger services sit running 24/7. A single Rust binary uses a fraction of the RAM of a multi-worker Python deployment—letting one small VPS comfortably host services that would otherwise need 4–8× the memory.
- Strict correctness boundaries: In our Accounting Reconciliation engine, deterministic matching processed 1,000,000 bank lines in 8.28 s on a laptop, and in Durable Runner our crash-tested journal accepted 1,000,000 of 1,000,000 jobs with bounded memory. Doing that cleanly in Python without dropping down to C/Rust extensions is fighting the runtime.
- Security-sensitive parsers and multi-tenant boundaries: Exhaustive
matchhandling, explicitResult/Optionerror paths, no implicitNonesurprises, and no runtime interpreter supply chain inside production containers make security audits dramatically cleaner. - Shipping CLIs and embedded runtimes: Handing an operator one binary with zero “please install Python 3.12 and activate
.venv” instructions eliminates half of all deployment support tickets.
The hybrid pattern that beats purity: Python + Rust together
Notice how the sharpest modern tools stopped treating Rust vs. Python as an all-or-nothing war:
uvandRuffreplaced slow Python packaging and linting tools with Rust binaries while serving Python developers.Pydantic v2andPolarsrun Rust engines behind clean Python APIs via PyO3.- AI product stacks often run Python for model evaluation, notebooks, and ML inference wrappers—while running Rust (or Go; see Go vs Rust for backend APIs) for the high-concurrency API gateway, auth, rate limiting, and durable execution harness.
Honest rule of thumb
- Start in Python if you are exploring ML/data workflows, scripting automation, or validating an early web product where I/O wait (DB + third-party APIs) dominates 95% of request time.
- Build in Rust when you are building long-lived infrastructure, high-throughput workers, low-memory self-hosted SaaS, strict security/ledger systems, or CLI/runtime tooling where predictable latency and single-binary ops matter from day one.
- Never rewrite in Rust just for speed until profiling proves Python—not your database queries or uncached API calls—is actually the bottleneck.
Frequently asked questions
Should I rewrite my Python FastAPI backend in Rust? Usually no—unless you have measured a real bottleneck that Python cannot solve cleanly, such as high memory bills per worker, CPU-bound parsing/streaming, unpredictable p99 tail latency, or distributing a single static binary. If your API spends 95% of its time waiting on PostgreSQL or LLM APIs, optimizing SQL queries and caching beats a rewrite every time.
Why do so many modern Python tools use Rust under the hood?
Tools like uv, Ruff, Pydantic v2, Polars, and Hugging Face tokenizers use Rust (via PyO3) for hot inner loops—parsing, validation, dependency resolution, and data transforms—while keeping Python as the ergonomic scripting and ML orchestration layer on top.
Is Rust better than Python for AI agents? It depends on which layer you are building. Python is faster for experimenting with ML models, notebooks, data pipelines, and PyTorch. Rust shines for the always-on production harness—durable job queues, strict MCP gateways, low-memory proxy servers, rate limiters, and crash-safe execution engines.