Quick Answer: The practical way to speed up a slow app is to rewrite slow functions in Rust, not the whole codebase. Profile the app, find the few functions that eat most of the runtime, port only those, and check each port against real recorded calls before you switch it on. The open-source fast-anything tool automates every step for Python, Node, Ruby and several other runtimes.

Most slow apps are slow in a handful of places. A Python fuzzy-dedupe job over 700 names took 4.91 seconds in the project's own benchmark, and nearly all of that time sat in one loop. Rewriting the whole app in Rust would take months, and the rewrite would still have to match the old behavior exactly. There's a narrower path. You rewrite slow functions in Rust, leave the rest of the code alone, and verify every port against real inputs. That's the approach behind fast-anything, a tool that covers Python, Node, Ruby, Java, Go, PHP, C, C++ and C#.

Profile first, because your guess is probably wrong

Most developers pick the slow function by gut feel, and gut feel is usually wrong. The fix is to measure. Python has cProfile in the standard library, and Node has --cpu-prof. Both show where wall-clock time actually goes, which is the only number that matters.

fast-anything's scan command does this step and ranks each function by two things: how much time it consumes and how portable it is. Portability matters because a function that reads a file handle, calls a network API, or depends on a mutable global can't be replaced cleanly. The tool flags those, so you don't waste an afternoon on a port that can't be enabled.

Here's the first thing practitioners learn the hard way. A function that looks expensive in isolation often isn't the bottleneck, while a function with a modest per-call cost called a million times is. Read the call counts, not just the timings.

The counter-intuitive part: port the outer loop

The popular advice says to find the hottest tiny function and rewrite it. That advice is incomplete, and here's why. Calling into Rust has a fixed cost on every crossing. When a tiny function runs millions of times, the boundary crossings can eat much of the time you saved.

The project's notes report 35× and 1.9× for ports that covered only the inner levenshtein function. The tool does the opposite. It ports the outermost loop it can, so the application crosses into Rust once instead of millions of times. Here's how that played out in the README's benchmarks:

  • Python fuzzy dedupe (700 names): 4.91s down to 42ms, about 116×
  • TypeScript fuzzy dedupe (2,000 names): 3.11s down to 155ms, about 20×
  • Go fuzzy dedupe (3,000 names): 3.02s down to 144ms, about 21×
  • Ruby fuzzy dedupe (400 names): 3.13s down to 228ms, about 14×
  • C mandelbrot (8 zoom levels): 431ms down to 127ms, about 3.4×

Those are the author's numbers, measured on an i5-10500 under Windows 11, except the C and C++ runs, which used a 4-core GitHub Actions Linux runner. Treat them as a strong signal, not a guarantee. Your hardware and call pattern will move the results, which is why the tool benchmarks the whole app with interleaved runs before it reports anything.

What the port actually looks like

Once you pick a function, port records up to 500 real calls made while your app runs. It then generates a one-function Rust crate and a TASK.md file describing the job. You hand that file to a coding agent such as Claude Code or Codex, or to any command that reads a prompt on stdin.

The crate is small on purpose. Compiles take seconds rather than minutes, and every port shares one .fast/target cache. Your application code stays as it was. Rust is opt-in per function.

The recorded calls do real work. In one of the README's demos, a port looked correct but compared bytes instead of characters. It was a plausible-looking mistake, and 148 of the 500 recorded calls caught it. Without the replay, that bug would have shipped as a silent data change on non-ASCII names.

Proof before you flip the switch

This is where most DIY attempts fail. Engineers test the port against a few hand-picked inputs and call it done. fast-anything's verify command replays every recorded call against the release-built port. It also derives extra cases the original function answers:

  • Edge values: NaN, positive and negative infinity, -0.0, zero, ±1
  • Text: non-ASCII strings and empty inputs
  • Size: inputs up to 16× larger than anything recorded
  • Shrunk inputs: tiny and random slices of recorded data

A port passes only when the values match, with floats compared within 1e-9, and when errors show up exactly where the original raises them. A port that's correct but slower per call than the original also stays disabled, because calling into Rust can cost more than the work it saves.

That 1e-9 tolerance is a choice, and you should own it. If your downstream code depends on bit-exact floating-point output, you'll need a stricter comparison. That's a trade-off the tool can't make for you.

Full rewrite, hand port, or targeted port?

ApproachScopeCost and timeMain riskRollback
Full rewrite in RustEntire appMonths; minute-long compiles; gigabytes of target/ (per README)All behavior must be re-proven at onceEffectively none once cut over
Hand-port one inner functionOne function, crossed on every callBenchmarked at 1.9× to 35× for inner-only ports (README)Per-call boundary cost can erase gainsManual revert
fast-anything outer-loop portOutermost loop it can portOne-function crate; seconds to compile; single enable commandDependent on deterministic, plain-data functionsdisable removes the marked block byte for byte

The third row is the one to start with when the work is CPU-bound and the function takes plain data. It's not the right tool for every app, which is the honest limit of the approach.

Rollback and the risks you still own

Every enabled port sits inside one marked block. disable removes it byte for byte, so your source returns to its exact prior state. If you need a quick escape hatch in production, FAST_ANYTHING_DISABLE=1 runs the original code without touching the files.

Here are the limits you should plan around:

  • Scope is narrow. The tool ports top-level, deterministic functions that take plain data such as numbers, strings, lists, dicts and typed arrays. Anything with side effects gets flagged, not ported.
  • Startup can dominate. The Java benchmark dropped from 3.50s to 1.18s. The function itself got about 11× faster, but JVM startup takes the rest of the time.
  • GPU kernels are out of scope. With Intel oneAPI SYCL code, only host functions get profiled and ported.
  • Rust is a dependency. You need a working toolchain from rustup. The doctor command checks this along with your runtimes and agents.

Here's where it gets interesting. Most of your time with this tool won't go to porting. It'll go to deciding which functions are worth porting, and the scan ranking is what makes that decision fast.

Frequently Asked Questions

What is fast-anything?

fast-anything is an open-source tool that profiles Python, Node, Ruby and other apps, then ports only the hot functions to Rust. It records real calls, verifies the Rust port against them, and swaps it in with a reversible marked block. It's distributed through npm and crates.io and is MIT licensed.

How do I rewrite slow functions in Rust without breaking behavior?

Profile the app to find functions that use the most time, then record real calls to those functions. Port one function at a time and replay every recorded call against the Rust version. Enable the port only after outputs match, including edge cases such as NaN, empty input and non-ASCII text.

Why does porting a small function sometimes make my app slower?

Every call from your runtime into Rust has a fixed overhead. A tiny function called millions of times can spend more time crossing that boundary than doing its work. Porting the outermost loop that calls it crosses the boundary once, which is why the outer loop often wins.

When should I skip the rewrite entirely?

Skip it when the slow part is I/O, a database query or a network call, since Rust won't speed those up. Also skip it when the function depends on mutable global state or side effects, because a verified port has to behave the same on every recorded input.

Pick one slow function and measure it today

Pick the slowest function your profiler reports, and check how often it's called. If the inner loop runs millions of times, look one level up at the loop that calls it. Run scan on that app, and if a candidate ranks high, port it and let verify decide whether it's safe to enable. You'll know within an afternoon whether it's worth it. Pass this approach to anyone whose Python, Node or Ruby service is slow and who's been told they need to rewrite slow functions in Rust across the whole codebase.