fast-anything Finds Your Slowest Function, Then Tells You to Ignore It
A Rust CLI that profiles Python, Node, Ruby, and eight other languages, hands the hot 5% to a coding agent, and gates every port behind replayed real calls. Its sharpest idea is about the cost of crossing a language boundary.

Don't rewrite it in Rust. Rewrite the 5% that's slow.
- fast-anything's sharpest idea is refusing to port the top-ranked function when a portable caller already covers it.
- Every crossing into Rust carries a fixed per-call toll, so one boundary crossing for a whole loop beats millions of tiny ones.
- The tool is a safety gate first: it records real calls, generates edge cases, and refuses to enable any port that fails or is slower per call.
- A full rewrite is months of irreversible work; a marked, reversible one-function port is something a team will actually approve.
A 35× Function That Made the App 1.9× Faster
A ported function that runs 35 times faster sounds like a clear win. In fast-anything's own benchmark for a Python fuzzy-deduplication app, porting the Levenshtein distance function to Rust delivered exactly that: 35× on the function. The application got 1.9× faster.
Both numbers come from the same run. That gap between them is the most interesting thing in the repository, and almost nobody who shares the project online mentions it. They share the star count instead.
The cause is the language boundary. Every call from Python into Rust pays a fixed toll: argument marshaling, the FFI hop, the return trip. A function called a few million times pays that toll a few million times. The Rust arithmetic is nearly free. The crossing is not.
fast-anything could have stopped there and shipped a porting tool. Instead it built a rule that stops you from making this mistake in the first place.
A caveat worth stating up front: these figures are project-authored example runs, not independently reproduced benchmarks. Treat them as a demonstration of a mechanism, not a guarantee about your codebase.
The Rule That Says "Port the Caller"
Before fast-anything recommends anything, it ranks every function in the profile by a single number. That number is the product of two factors: how much of the runtime the function accounts for, and how portable it is.
pub const WORTH_IT: f64 = 0.02;
h.share = (h.cumtime / wall).clamp(0.0, 1.0);
h.portability = if h.portable() { h.portability.clamp(0.0, 1.0) } else { 0.0 };
h.score = h.share * h.portability;
The share uses cumulative time, so an outer function's share includes the work of everything it calls. Portability is a score between 0 and 1, and it is forced to 0 for any function with blockers. Nothing below a 2% share of runtime clears the WORTH_IT floor.
Then the ranking does something unexpected. For each portable function, it looks for a portable caller in the same file whose share is at least 90% of the callee's share. If one exists, the callee is marked as covered and its score is set to zero.
// a portable caller in the same file that carries the work
*share >= 0.9 * h.share
This is the outer-loop rule, and it is the reason porting the caller beat porting the callee in that benchmark. One crossing for the whole loop replaces millions of small crossings. The tool does not just find your slowest function. It finds your slowest function and then tells you to port the one above it.
The behavior is pinned by two unit tests. outer_loop_covers_inner_function checks that a portable caller demotes its callee. portable_beats_bigger_but_blocked checks that a blocked main holding 100% of runtime ranks below a portable lev holding 90%. The second test is the whole philosophy in one assertion: coverage matters more than raw share, and portability is a hard gate.
Be honest about the 0.9 threshold, though. It is a tuned heuristic, not a derived constant. A caller that spends 91% of its time in the callee and 9% elsewhere is treated as the cover. That is a reasonable call, but the test suite does not sweep the threshold to show that 0.9 is optimal.
Why Anyone Builds This
Now that the mechanism is on the table, the origin makes more sense. The pitch is not "rewrite your service in Rust." It is "rewrite the 5% that is slow."
A full rewrite is a non-starter for most teams. It takes months, it touches everything, it is nearly impossible to review, and it is irreversible once it lands in production. A narrow port of one function, wrapped in a marked block you can strip out byte for byte, is something a team will actually approve. The intended user is a developer who already has a coding agent in their workflow and wants a measurable, undoable change in one specific place.
The tool ships as a Rust CLI, published on both npm and crates.io under the MIT license. It supports eleven languages: Python, JavaScript and TypeScript, Ruby, Java, Kotlin, Go, PHP, C, C++, C#, and R. Python and Node get native bindings through PyO3 and napi-rs. The other languages converge on a shared C ABI with JSON passed across the boundary. There is also a Claude Code plugin, an MCP server exposing eight tools, and a skill file, so an agent can drive the whole loop.
Scan, Port, Verify, Enable, Bench
The pipeline runs in five stages, with a report at the end. Each stage is a function that opens the project, does its work, and persists the result to a state file that every later command reads.
- scan profiles the app and ranks functions by share times portability. It detects the real interpreter, unwrapping environment runners like
uv runorpoetry runso the profiler hooks the actual process. - port re-runs the app, records up to 500 real calls to the chosen function, and generates a one-function Rust crate plus a task brief for the agent.
- verify builds the crate in release mode and replays every recorded call, plus derived and edge cases, against the original's answers.
- enable / disable inserts or removes the Rust call site inside a marked block.
- bench times the whole app, original versus Rust, in interleaved runs.
- report produces markdown and an SVG card ready for a pull request.
Two details show unusual care. The first is a hidden __replay subcommand. Verification runs in a child process, and the comment in the source says why: "so a crashing port can't take it down." A Rust port that segfaults gets caught as a failed case instead of killing the tool.
The second is staleness. At port time, fast-anything snapshots the exact source lines of the original function. Later, when you ask it to enable or bench, it checks that those lines still exist in the file. If you have edited the function since the port was recorded, the tool knows the recorded calls and the Rust port may no longer match, and it can say so. It is text matching rather than AST hashing, which is less robust but works across all eleven languages without writing a parser for each one.
The Gates
Four constraints define the shape of the tool. They are also the fastest way to tell whether your own codebase is a candidate.
The portability gate. Any function with blockers gets its portability forced to zero and drops out of contention. Blockers are the things a Rust port cannot faithfully reproduce: unsupported types, mutating calls, and the like.
The mutation gate. If the recorded calls show the function mutating its arguments, porting bails with an instructive message rather than a stack trace.
A Rust port can only return a value, so it would drop those changes.
Have the function return the new value instead, then scan again.
That is a semantic constraint enforced at recording time, not at compile time, and the error tells you exactly how to restructure the function so the tool can help you.
The plain-data gate. If no calls were usable, the error lists the unsupported types it saw and the ones it supports: numbers, strings, bytes, lists, tuples, dicts, sets. Anything richer than that needs a different approach.
The staleness gate. As described above, a port whose source has drifted since recording is flagged rather than silently enabled.
What It Is Not
fast-anything does not invent a new compiler, profiler, or binding technology. Every piece it uses already exists. Its contribution is the workflow that composes them, so read the table below as a map of layers rather than a scoreboard.
| Tool | What it is | Finds hotspots | Generates the port | Verifies behavior | Reversible | Multi-language |
|---|---|---|---|---|---|---|
| fast-anything | Profile, port, verify, toggle workflow | Yes | Yes, via agent | Yes, replayed calls | Yes | Yes, 11 languages |
| py-spy | Sampling profiler for Python | Yes | No | No | No | No |
| Scalene | Python CPU and memory profiler | Yes | No | No | No | No |
| cProfile | Python standard profiler | Yes | No | No | No | No |
| Cython | Compiles Python to C extensions | No | Partial, hand-written | No | Partial | No |
| Numba | JIT for numerical Python | No | No | No | No | No |
| PyO3 + maturin | Rust and Python binding toolkit | No | No | No | No | No |
| Full rewrite | Reimplement the whole app | No | No | No | No | No |
Profilers diagnose. Compilers and JITs accelerate within one ecosystem. FFI frameworks help you write bindings by hand. fast-anything is the only row that runs the whole loop and hands you a one-command undo. That is a composition, not a breakthrough, and it is worth saying plainly.
Rust, or Hindsight?
The most substantive pushback came from a Hacker News thread, and it deserves a fair hearing. The argument: algorithm and data-structure choices, plus the hindsight of rewriting anything with performance in mind, may explain as much of the speedup as the language does.
I would like to argue that one could make most codebases 50% faster if rewritten from scratch with performance in mind even in the same language.
The counter to that counter is also on the thread, and it is measured rather than dismissive.
I mean, it's definitely both. Of course there can be algorithmic improvements, but a like-for-like rewrite of Python code into Rust can often be 10x faster.
Here is the honest part: fast-anything's own design partly concedes the point. Choosing the outer loop over the inner function is a structural decision, not a language decision. The tool is telling you to change where the work happens, and Rust is just the vehicle. Whether the 35× came from the language or from the restructuring is not something the project's example runs can settle.
That is the open question worth carrying away. If the speedup is mostly hindsight, then any disciplined rewrite would capture it, and the language is a detail. If it is mostly the boundary, then the outer-loop rule is the real product and everything else is packaging. fast-anything is a bet that it is both, and it gives you a way to find out on your own code without committing to anything you cannot undo.





