NewsCrawler.org

fast-anything: rewrite only the slow functions in Rust, not the whole app

Don't rewrite it in Rust. Rewrite the 5% that's slow: profile Python, Node or Ruby apps, port the hot functions with your coding agent, prove they behave the same. - EL4CTEO/fast-anything
Image: github.com

fast-anything is a tool that finds the slow functions in a program, has a coding agent port only those functions to Rust, and checks the port before switching it in. It is installed with npm or cargo, and one command runs the whole process, which can be reversed at any time.

The port is checked against 500 real recorded calls and against extra cases: edge values such as NaN, ±infinity and -0.0, empty inputs, inputs up to 16× bigger, and shrunk inputs. In one example, an early port failed 148 of 500 calls because it compared bytes instead of characters. Nothing is enabled until every case matches (floats within 1e-9), and a port that is slower per call than the original is not enabled either. FAST_ANYTHING_DISABLE=1 runs the original.

fast-anything ports the outermost loop it can, not the small function called inside it, so the app crosses into Rust once instead of millions of times. Porting only the inner levenshtein function gave 35× and 1.9× in the author's runs. Each port is built as a one-function crate[1], and all ports share one .fast/target cache, so compiling takes seconds rather than minutes. The tool is also available as an MCP server[2] for Claude Code, Codex and Cursor, and as a Claude Code plugin.

Repository fast-anything github.com

A tool that profiles Python, Node or Ruby apps, ports only their slow functions to Rust with a coding agent, and checks the port matches the original.

Stars: 1,321Forks: 86License: MITUpdated:

Read the original github.comDiscussion

Discussion

Commenters mostly doubt the approach: they say a hot spot covering 5% of the code is rare, and that slowdowns are usually spread across the whole system, citing Amdahl's law. Others report success with a similar method, moving route matching and JSON encoding in a Python web framework to Rust with PyO3, and one commenter suggested asking an agent to profile the app and rewrite the bottleneck instead of using a repo.

Sources

  • GitHub

    Fast-Anything: Don't rewrite it in Rust. Rewrite the 5% that's slow

    163 comments

  • KRGeekNews KO

    Fast-Anything: 전체를 Rust로 재작성하지 말고, 느린 5%만 재작성하라

    14 points1 comment

Published: First seen: Читать по-русски

Open as a page