Skip to content

Don't rewrite it in Rust. Rewrite the 5% that's slow: profile your app, port the hot functions with your coding agent, prove they behave the same. Python, JS/TS, Ruby, Java, Kotlin, Go, PHP, C/C++, C#, R.

Merge #141

EL4CTEO455c9cc54df2
diff --cc README.md
index 62006d9,9f62a32..7df87f5
--- a/README.md
+++ b/README.md
@@@ -56,8 -56,10 +56,10 @@@ Or step by step
<p align="center"><img src="https://raw.githubusercontent.com/EL4CTEO/fast-anything/main/docs/assets/verify.gif" alt="verify catches a wrong port" width="820"></p>
-That port looked right but compared bytes instead of characters. 148 of 500 real calls caught it. On top of the recorded calls, fast-anything derives extra cases and lets the original answer them: edge cases (NaN, ±infinity, -0.0, zero and ±1, non-ASCII text, empty and up to 16× bigger inputs) and shrunk inputs (tiny and random slices). Nothing is enabled until every case matches: same values (floats within 1e-9), errors where the original errors. A port that is right but slower per call than the original (calling into Rust costs more than the work saved) isn't enabled either. `FAST_ANYTHING_DISABLE=1` runs the original any time.
+That port looked right but compared bytes instead of characters. 148 of 500 real calls caught it. On top of the recorded calls, fast-anything derives extra cases and lets the original answer them: edge cases (NaN, ±infinity, -0.0, zero and ±1, non-ASCII text, empty and up to 16× bigger inputs) and shrunk inputs (tiny and random slices). Nothing is enabled until every case matches: same values (floats within 1e-9 of their size or of the largest value in the same list, -0.0 not 0.0), errors where the original errors. A port that is right but slower per call than the original (calling into Rust costs more than the work saved) isn't enabled either. `FAST_ANYTHING_DISABLE=1` runs the original any time.
+ Every 5th recorded call (from 5 calls up) is held out of the crate folder the agent works in: verify replays it too but reports a mismatch there without the values, so a port that special-cases the calls it was shown still fails.
+
## Results
Real runs on an i5-10500, Windows 11 (C and C++: a 4-core GitHub Actions Linux runner). Reproduce them from [`examples/`](examples).
diff --cc src/native.rs
index 16eb18a,fbcf33f..8b0c37a
--- a/src/native.rs
+++ b/src/native.rs
@@@ -203,10 -210,9 +210,10 @@@ Only edit files in this folder. Don't t
## The original ({file}:{line})\n\n{fence}{lang}\n{source}\n{fence}\n\n\
{helper_md}\
## Real calls\n\n\
- fast-anything recorded {recorded} real calls (out of {seen} while the app ran). Arguments arrive as JSON. A few:\n\n{fence}\n{samples}\n{fence}\n\n\
+ fast-anything recorded {recorded} real calls (out of {seen} while the app ran). Arguments arrive as JSON. A few:\n\n{fence}\n{samples}\n{fence}\n\n{held}\
## Rules\n\n\
- Same result for every input, edge cases included: empty input, zero, negatives, non-ASCII text, very long input. verify tests these too.\n\
+- Floats must match within 1e-9 of their size (or of the largest value in the same array), and zeros keep their sign: -0.0 is not 0.0. Keep the same order of float operations.\n\
{rules}\
- Return `Err(message)` where the original would fail.\n\
- Make it fast: no needless allocation, borrow, `with_capacity`, fast paths for common cases. Threads are fine if the result is the same.\n\
diff --cc src/ruby.rs
index ea7002a,914a298..3277a42
--- a/src/ruby.rs
+++ b/src/ruby.rs
@@@ -233,10 -233,9 +233,10 @@@ Only edit files in this folder. Don't t
## The original ({file}:{line})\n\n{fence}ruby\n{source}\n{fence}\n\n\
{helper_md}\
## Real calls\n\n\
- fast-anything recorded {recorded} real calls (out of {seen} while the app ran). Arguments arrive as JSON. A few:\n\n{fence}\n{samples}\n{fence}\n\n\
+ fast-anything recorded {recorded} real calls (out of {seen} while the app ran). Arguments arrive as JSON. A few:\n\n{fence}\n{samples}\n{fence}\n\n{held}\
## Rules\n\n\
- Same result for every input, edge cases included: empty input, zero, negatives, NaN and infinity, non-ASCII text, very long input. verify tests these too.\n\
+- Floats must match within 1e-9 of their size (or of the largest value in the same Array), and zeros keep their sign: -0.0 is not 0.0. Keep the same order of float operations.\n\
- Change the `serde_json::Value` parameter and return types to concrete ones: they're deserialized for you.\n\
- Ruby strings index by character: use `.chars()` (or bytes only after checking `is_ascii()`).\n\
- Ruby Integers don't overflow. `i64` is fine unless the recorded values are bigger. Keep Integer vs Float as Ruby has it.\n\