Fast-anything scans a Python script, isolates a hot function, and replaces it with a compiled Rust crate.
*Fast-anything profiles Python, Node, Ruby and other runtimes, isolates the hot 5% of code, ports those functions to Rust, and validates byte‑for‑byte equivalence. The claim is dramatic: up to 116× faster on real‑world deduplication tasks, with compile times measured in seconds.*
The open‑source project fast-anything promises to slash runtime latency without the months‑long effort of a full Rust rewrite. By profiling an app, isolating the slowest five percent of functions, and porting only those to Rust, the tool claims speedups that dwarf traditional optimization. The approach hinges on a coding agent—Claude, Codex or any stdin‑prompted tool—to generate a one‑function Rust crate, then replay up to 500 real calls to prove identical behavior. If the port passes a battery of edge‑case tests, it is swapped in with a single reversible command. The claim is bold: rewrite the 5% that’s slow, not the whole codebase, and reap performance gains measured in seconds rather than minutes.
Fast-anything scans an application, ranks functions by execution time and portability, then asks a coding agent to port the top offenders to Rust. Each port becomes a one‑function crate compiled with the user's Rust toolchain. The tool records up to 500 real calls, builds a Rust crate, replays the calls, and swaps the Rust implementation in place of the original code. The swap is reversible with a single command. No full rewrite is required; only the identified hot functions move to Rust, leaving the rest of the code untouched.
Verification runs the recorded calls against the Rust port and checks that every output matches the original down to floating‑point tolerance of 1e‑9. It also reproduces errors exactly. Fast-anything generates extra edge cases—NaN, ±infinity, -0.0, zero, ±1, non‑ASCII text, empty inputs, inputs up to 16× larger, tiny random slices—and requires the port to pass all of them before enabling it. If the Rust call is slower per invocation, the port stays disabled. Setting FAST_ANYTHING_DISABLE=1 forces the original code to run at any time.
Benchmarks on an i5‑10500 show dramatic gains. A Python fuzzy dedupe of 700 names fell from 4.91 seconds to 42 ms, a 116× speedup. TypeScript dropped from 3.11 s to 155 ms (20×). PHP fell from 2.94 s to 53 ms (55×). Go fell from 3.02 s to 144 ms (21×). Ruby fell from 3.13 s to 228 ms (14×). C# fell from 4.03 s to 312 ms (13×). Java fell from 3.50 s to 1.18 s (3×), noting JVM startup overhead. C and C++ saw 3.4× and 2.7× respectively. The tool only ports the outermost loop, avoiding millions of cross‑language calls, which explains why the gains are far higher than a naïve per‑function port.
Fast-anything offers bindings for Python 3.10+, JavaScript/TypeScript (Node 22+), Ruby 3.3+, Java 22+, Go 1.22+, PHP 8.1+, C and C++ (gcc, clang, Intel oneAPI), and C#/.NET 8+. Each language uses the appropriate foreign‑function interface: PyO3 for Python, napi‑rs for Node, Ruby’s Fiddle, Java’s FFM API, Go’s cgo, PHP’s FFI, and NativeLibrary for .NET. The tool can profile top‑level, deterministic functions that accept plain data—numbers, strings, lists, dicts, typed arrays—and static methods in Java, C#, and PHP. Functions that cannot yet be moved are reported by the scan step.
Fast-anything focuses on the 5% of functions that are slow, rewriting only that slice.
The tool records up to 500 real calls per function before building the Rust port.
The Python fuzzy dedupe benchmark dropped from 4.91 seconds to 42 ms, a 116× improvement.
If the benchmarks hold across production workloads, fast-anything could reshape how teams approach performance bottlenecks—favoring surgical Rust ports over monolithic rewrites. The tool’s emphasis on real‑call verification and reversible swaps lowers risk, while its multi‑language support broadens appeal. As developers chase ever‑tighter latency targets, a solution that delivers month‑level gains in seconds may become a new standard in the optimization toolbox.
Sources: [Hacker News – Fast-Anything: Don't rewrite it in Rust. Rewrite the 5% that's slow]