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.
Rust agent-skillsai-agentsclaude-codeclaude-code-plugincodexdeveloper-toolsffimcpmcp-servernapi-rsnodejsoptimizationperformanceprofilerpyo3pythonrewrite-it-in-rustrubyrusttypescript
TASK.md: an empty f64 sum is -0.0 in Rust
Milosza0f7cac6c5f1
diff --git a/src/native.rs b/src/native.rsindex e02a550..db8ca59 100644--- a/src/native.rs+++ b/src/native.rs@@ -214,6 +214,7 @@ fast-anything recorded {recorded} real calls (out of {seen} while the app ran).## 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\+- `.sum()` of an empty float iterator is -0.0 in Rust: start float sums with `fold(0.0, |a, x| a + x)`.\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 --git a/src/node.rs b/src/node.rsindex 132763d..61b8772 100644--- a/src/node.rs+++ b/src/node.rs@@ -462,6 +462,7 @@ fast-anything recorded {recorded} real calls (out of {seen} while the app ran).Use `s.encode_utf16()` for anything index- or length-based (bytes are fine after checking `is_ascii()`).\n\- JavaScript numbers are f64. Integer math is exact only up to 2^53; use `f64` unless the values are clearly small integers.\n\- Numbers must match within 1e-9 of their size (or of the largest value in the same array), and zeros keep their sign: -0 is not 0. Keep the same order of float operations.\n\+- `.sum()` of an empty float iterator is -0.0 in Rust: start float sums with `fold(0.0, |a, x| a + x)`.\n\- Where JavaScript throws, return `Err(Error::from_reason(...))`.\n\- Each call crosses from JavaScript into Rust: keep conversions cheap, don't clone big inputs.\n\- Make it fast: no needless allocation, borrow, `with_capacity`, fast paths for common cases.\n\diff --git a/src/python.rs b/src/python.rsindex 53b7b18..926b668 100644--- a/src/python.rs+++ b/src/python.rs@@ -784,6 +784,7 @@ fast-anything recorded {recorded} real calls (out of {seen} while the app ran).- Python `str` indexes by Unicode code point: use `.chars()` (or bytes only after checking `is_ascii()`).\n\- Python ints don't overflow. `i64` is fine unless the recorded values are bigger.\n\- Floats must match within 1e-9 of their size (or of the largest value in the same list), and zeros keep their sign: -0.0 is not 0.0. Keep the same order of float operations.\n\+- `.sum()` of an empty float iterator is -0.0 in Rust: start float sums with `fold(0.0, |a, x| a + x)`.\n\- Where Python raises, raise too (`PyValueError::new_err(...)`, `PyKeyError`, ...).\n\- Make it fast: no needless allocation or cloning, borrow inputs, `with_capacity`, fast paths for common cases.\n\- std only, unless a crate clearly pays off. Keep the function and module names as they are.\n\diff --git a/src/python/runner.py b/src/python/runner.pyindex dd6e08f..3d2ef4c 100644--- a/src/python/runner.py+++ b/src/python/runner.py@@ -211,6 +211,7 @@ def same_floats(np, a, b):if not np.array_equal(a[infinite], b[infinite]) or np.any((a == b) & (np.signbit(a) != np.signbit(b))):return Falsex, y = a[finite], b[finite]+ # One scale for the whole array: a 2-D array isn't scaled per row, so it's looser than nested lists.scale = np.abs(a[np.isfinite(a)]).max(initial=0.0)with np.errstate(over="ignore"):return bool(np.all((x == y) | (np.abs(x - y) <= 1e-9 * np.maximum(np.maximum(np.abs(x), np.abs(y)), scale))))diff --git a/src/r.rs b/src/r.rsindex 0e1a4d9..3ac0021 100644--- a/src/r.rs+++ b/src/r.rs@@ -532,6 +532,7 @@ fast-anything recorded {recorded} real calls (out of {seen} while the app ran).## Rules\n\n\- Same result for every input, edge cases included: empty vectors, zero, negatives, NA, non-ASCII text, very long input. verify tests these too.\n\- Doubles must match within 1e-9 of their size (or of the largest value in the same vector), and zeros keep their sign: -0 is not 0. Keep the same order of float operations.\n\+- `.sum()` of an empty float iterator is -0.0 in Rust: start float sums with `fold(0.0, |a, x| a + x)`.\n\- R strings index by character: use `.chars()` (or bytes only after checking `is_ascii()`). R indexes from 1.\n\- Make it fast: no needless allocation, borrow, `with_capacity`, fast paths for common cases.\n\- Keep the function name.\n\n\diff --git a/src/ruby.rs b/src/ruby.rsindex 3277a42..e544c1e 100644--- a/src/ruby.rs+++ b/src/ruby.rs@@ -237,6 +237,7 @@ fast-anything recorded {recorded} real calls (out of {seen} while the app ran).## 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\+- `.sum()` of an empty float iterator is -0.0 in Rust: start float sums with `fold(0.0, |a, x| a + x)`.\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\