A Python fuzzy dedupe over 700 names takes 4.91s. Replace one function with Rust via PyO3 and the whole app runs in 42ms. That's 116x, and everything else is still the same Python you had yesterday.

That number comes from the README of fast-anything, an MIT-licensed CLI (2.6k stars as I write this) whose tagline is the whole argument: "Don't rewrite it in Rust. Rewrite the 5% that's slow." It profiles your app (Python, Node, Ruby, Go, Java, PHP, C# and a few more), has a coding agent port the hot function to Rust, and refuses to switch the port on until it behaves the same as the original on real recorded calls. That last part is why I think it's worth a look, and the benchmark table also says something unflattering about a lot of full rewrites.

Most full Rust rewrites are about the résumé

My position: most "we rewrote it in Rust" projects are ego with a benchmark attached. A profiler would have told you where the time goes in an afternoon. The rewrite takes months, and the README is blunt about what comes with it: "months, minute-long compiles and gigabytes of target/".

A commenter on the Hacker News thread (200 points, 163 comments) said it better than I can. caymanjim says people rewrite in Rust "so that they can make HN posts about rewriting a thing in Rust that didn't need rewriting."

There are honest reasons to rewrite. Memory safety is one, and several people in the thread argued it. But if the ticket says "it's slow", the rewrite is the most expensive way to fix it.

How fast-anything speeds up Python with Rust

Install it, have a Rust toolchain via rustup, and point it at a realistic workload:

npm i -g @el4cteo/fast-anything # or: cargo install fast-anything fast-anything go --agent claude -- python app.py 

--agent takes claude, codex, or any command that reads a prompt on stdin. If you'd rather drive each stage by hand, the subcommands are:

command what it does
scan -- <cmd> profiles the app, ranks functions by time × how portable they are
port [id] records up to 500 real calls, creates a one-function Rust crate + TASK.md
verify release-builds the port and replays every recorded call
enable / disable swaps the Rust in or out (one marked block, removed byte for byte)
bench times the whole app, original vs Rust, interleaved runs
report markdown + SVG card for your PR
doctor checks Rust, your runtimes and your agents

Python bindings use PyO3 and need Python 3.10+. Every port is its own small crate, and all of them share one .fast/target cache that you can delete whenever you like. If something looks off in production, FAST_ANYTHING_DISABLE=1 runs the original code.

scan wants "a representative workload, not the test suite." Take that seriously. Profile your unit tests and you'll end up optimizing your fixtures.

Why porting the outer loop beat porting levenshtein

This is the part I'd want every "just add a Rust extension" blog post to cover.

Fuzzy dedupe is the textbook case. You compare every name with every other name, and levenshtein is where the time goes. The obvious move is to port levenshtein. The README reports that porting only the inner levenshtein gave 35× and 1.9×. It doesn't say which benchmarks those two figures came from, but compare 35× with the 116× headline. The tool deliberately "ports the outermost loop it can, not the tiny function called inside it."

The reason is the boundary. Port the inner function and Python crosses into Rust once per pair of names, which for a quadratic loop can mean millions of crossings. Each crossing converts arguments and return values. Port the loop instead and you cross once, and Rust does all the comparisons on its own side.

Not everyone in the thread was convinced. efficax argued the FFI boundary "often means you lose any gains from rust to packaging up the data." ben-schaaf disagreed: "Not really true in Python. Data is already in the form of C structs". The outer-loop approach mostly settles the argument by paying the conversion once.

The tool also enforces this. A port that is correct but slower per call "isn't enabled either," because the call overhead can cost more than the work it saves. Since 0.6.2, go --agent sends a slow-but-correct port back to the agent for another try and keeps the best correct attempt. You can override it with enable --force, and then the slowdown is on you.

Verification is the actual product

The obvious objection to the tool is that "have Claude rewrite my hot path in Rust" is something you can type into any agent today. raincole said so on HN: "You can literally just type 'profile this app and find out the performance bottleneck' then 'rewrite it in rust' in your agent TUI".

Sure. Then the agent gives you a function that compiles and looks right, and it's wrong for any name with an accent in it.

That's the README's own demo. A port "compared bytes instead of characters. 148 of 500 real calls caught it." Catching that is the job of verify, and it's the part of fast-anything that earns its keep:

  • It replays up to 500 real calls recorded from your actual workload.
  • It adds edge cases, with the original code supplying the expected answers: "NaN, ±infinity, -0.0, zero and ±1, non-ASCII text, empty and up to 16× bigger inputs". The 0.5.0 changelog spells out non-ASCII as accents, CJK, emoji and combining marks.
  • Floats must match within 1e-9. The port must raise where the original raises, and in Python that means the same exception type. A Rust panic doesn't count.
  • It tells ints from floats and tuples from lists.
  • If the Rust changed after verify, build refuses to put it live.

Five hundred recorded calls is not a proof, and the README's "Proof, not vibes" slogan oversells it a bit. If none of your recorded inputs reach a branch, nothing checks that branch. Still, it beats the alternative most people actually use, which is "the agent said the tests pass."

Where this approach breaks

The README's benchmarks (an i5-10500 on Windows 11; C and C++ on a 4-core GitHub Actions Linux runner) show the limits plainly. These are whole-app times, not microbenchmarks:

app before after
Python fuzzy dedupe (700 names) 4.91s 42ms, 116×
PHP fuzzy dedupe (600 names) 2.94s 53ms, 55×
Go fuzzy dedupe (3,000 names) 3.02s 144ms, 21×
TypeScript fuzzy dedupe (2,000 names) 3.11s 155ms, 20×
Ruby fuzzy dedupe (400 names) 3.13s 228ms, 14×
C# fuzzy dedupe (4,000 names) 4.03s 312ms, 13×
C mandelbrot (8 zoom levels) 431ms 127ms, 3.4×
Java fuzzy dedupe (4,000 names) 3.50s 1.18s, 3× (11× on the function)
C++ fuzzy dedupe (6,000 names) 3.02s 1.09s, 2.7×

The slower the host language, the bigger the win, which is what you'd expect. For Java, the README says the rest of the time is JVM startup. Bolwin on HN said the results section "feels a bit like a joke," since C and C++ got rewritten in Rust for performance, and dellamonica pointed out the C# version is single threaded while the Rust one isn't. I read the compiled-language rows as mostly parallelism, with a little extra on top.

Other limits:

  • It only ports top-level, deterministic functions that take plain data. I/O, randomness, globals and functions that mutate their arguments in place are out. In Python that means module-level functions and @staticmethods, plus dataclasses, NamedTuples and numeric NumPy arrays.
  • Amdahl's law still applies. ThouYS made the strongest counterpoint in the thread: sometimes "the true performance hog is like sand, spread across the system." If scan shows a flat profile, no port will save you.
  • There may already be a library for it. dejaydev asked whether the result beats RapidFuzz, the maintained fuzzy-matching library. That's a fair question, and the README doesn't answer it.
  • Someone has to own the Rust. Almondsetat's worry, the trickiest code ending up "in a language you don't even know", is real. I'm fine with a 200-line single-function crate that sits behind a kill switch. A whole codebase in that state is a different matter.

What to do today

  1. Profile a real workload before you open a rewrite RFC.
  2. If one CPU-bound, pure function dominates, check for an existing C-backed library (numpy, RapidFuzz) first.
  3. If there isn't one, port the outermost loop, not the inner helper.
  4. Don't ship any AI-written port until it has been replayed against real recorded inputs and the nasty floats and Unicode.
  5. Benchmark end to end, and keep the off switch.

fast-anything automates steps 3 to 5. You can do them by hand too, but most people who say they will end up skipping step 4.

So: have you done a full Rust rewrite? Was it worth it, or would porting the slow 5% have gotten you the same result? I'd especially like to hear from anyone whose profile turned out to be all sand and no hotspot.

Sources