Fast-Anything: don't rewrite it all in Rust, just the slow functions
Translated by a model; the original is in Russian.
"Rewrite it in Rust" has long been a meme. The author of fast-anything offers a humbler alternative: "Don't rewrite it in Rust. Rewrite the 5% that's slow." A full rewrite, he argues, costs months of work, minute-long compiles and gigabytes of target/, while most of the runtime usually sits in just a few functions.
How it works
The tool finds those functions, has a coding agent port only them to Rust, checks the port against real recorded calls and swaps it in. It takes one command and is fully reversible:
fast-anything go --agent claude -- python app.py
Step by step: scan profiles the app and ranks functions by time multiplied by portability, port records up to 500 real calls and creates a one-function crate with a TASK.md for the agent, verify release-builds the port and replays every call, and enable and disable swap the Rust version in or out. There is also bench for timing, report for a pull-request summary and doctor for checking the environment. The agent can be Claude, Codex or any program that reads a prompt from standard input.
Proof, not vibes
The author gives an example: a port looked right but compared bytes instead of characters, and 148 of 500 recorded calls caught it. Beyond real data, the tool derives edge cases (NaN, infinities, -0.0, non-ASCII text, empty inputs and inputs up to 16 times larger) and shrunk samples, which the original answers. A port is enabled only when every result matches (floats within 1e-9) and errors occur wherever the original errors. A correct port that is slower per call isn't enabled either. Setting FAST_ANYTHING_DISABLE=1 brings back the original code at any time.
Results
On a fuzzy name-deduplication task, the Python version went from 4.91 s to 42 ms (116×), PHP gained 55×, Go and TypeScript about 20×, Ruby and C# 13–14×. Java gained only 3×: the function itself got 11× faster, but JVM startup eats the rest. Even C and C++ saw speedups of 2.7–3.4×.
The key trick is porting the outermost loop rather than the small function inside it, so the app crosses the language boundary once instead of millions of times. Porting only the inner Levenshtein function yielded 35× and 1.9×.
Languages and integrations
Python is bound via PyO3, JavaScript and TypeScript via napi-rs. Ruby, Java, Go, PHP, C, C++ and C# share a single C bridge: the port is a plain Rust library with one entry point that takes and returns JSON. Eligible functions are deterministic, top-level and work on plain data; for everything else, scan explains why it can't move yet.
The tool installs via npm or cargo, plugs into Claude Code as a plugin, ships an MCP server with eight tools and is released under the MIT license. The repository has more than 1.1k stars on GitHub.
Source: Hacker News
Comments
Sign in, to comment.