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
Merge #85: Windows py launcher version selectors (drops the --version: end-to-end case: the legacy launcher rejects it)
EL4CTEO3a6e5ed66c38
diff --cc src/python.rsindex f26a4bd,d5f239f..6c63da2--- a/src/python.rs+++ b/src/python.rs@@@ -818,6 -890,6 +890,127 @@@ pub fn disable(ctx: &Ctx, port: &Port)mod tests {use super::*;++ #[test]++ fn py_launcher_version_selectors_split_and_strip_for_bench() {++ let argv = |s: &str| s.split_whitespace().map(String::from).collect::<Vec<_>>();++ for (prog, raw, want_sel, want_rest) in [++ ("py", "-3 app.py", Some("-3"), vec!["app.py"]),++ ("py", "-3.13 app.py arg1", Some("-3.13"), vec!["app.py", "arg1"]),++ ("py", "-3.13.1 app.py", Some("-3.13.1"), vec!["app.py"]),++ ("py", "-3t app.py", Some("-3t"), vec!["app.py"]),++ ("py", "-3.13t-64 app.py", Some("-3.13t-64"), vec!["app.py"]),++ ("py", "-V:3.13 -u app.py", Some("-V:3.13"), vec!["-u", "app.py"]),++ ("py", "--version:3.13 app.py", Some("--version:3.13"), vec!["app.py"]),++ ("py", "-V: app.py", Some("-V:"), vec!["app.py"]),++ ("py", "--version: app.py", Some("--version:"), vec!["app.py"]),++ ("py", "-3.13-64 app.py", Some("-3.13-64"), vec!["app.py"]),++ ("C:\\Windows\\py.exe", "-V:PythonCore/3.13 app.py", Some("-V:PythonCore/3.13"), vec!["app.py"]),++ ("py", "app.py", None, vec!["app.py"]),++ ("py", "-u app.py", None, vec!["-u", "app.py"]),++ ("py", "-0 app.py", None, vec!["-0", "app.py"]),++ ("py", "-1 app.py", None, vec!["-1", "app.py"]),++ ("py", "-10 app.py", None, vec!["-10", "app.py"]),++ ("py", "-V app.py", None, vec!["-V", "app.py"]),++ ("py", "--VERSION:3.13 app.py", None, vec!["--VERSION:3.13", "app.py"]),++ ("python", "-3 app.py", None, vec!["-3", "app.py"]),++ ("python", "app.py", None, vec!["app.py"]),++ ("python3", "-V:3.13 app.py", None, vec!["-V:3.13", "app.py"]),++ ] {++ let args = argv(raw);++ let (sel, rest) = split_py_launcher_selector(prog, &args);++ assert_eq!(sel, want_sel, "{prog} {raw}");++ assert_eq!(rest, want_rest.as_slice(), "{prog} {raw}");++ }++++ // Verify bench_command strips the selector on Windows and leaves non-Windows untouched.++ let dir = std::env::temp_dir().join(format!("fa-py-bench-cmd-{}", std::process::id()));++ let _ = fs::remove_dir_all(&dir);++ fs::create_dir_all(&dir).unwrap();++ let mut ctx = Ctx::open(&dir).unwrap();++ ctx.state.runtime = Some("C:\\Python313\\python.exe".into());++ for (cmd, win_want, non_win_want) in [++ (argv("py -3 app.py"), argv("app.py"), argv("-3 app.py")),++ (argv("py -3.13 app.py --flag"), argv("app.py --flag"), argv("-3.13 app.py --flag")),++ (argv("py -V:3.13 -u app.py"), argv("-u app.py"), argv("-V:3.13 -u app.py")),++ (argv("py app.py"), argv("app.py"), argv("app.py")),++ (argv("python app.py"), argv("app.py"), argv("app.py")),++ ] {++ ctx.state.command = cmd.clone();++ let (exe, got) = crate::backend::Lang::Python.bench_command(&ctx).unwrap();++ assert_eq!(exe, "C:\\Python313\\python.exe");++ let want = if cfg!(windows) { win_want } else { non_win_want };++ assert_eq!(got, want, "{cmd:?}");++ // Verify profile and record pass the exact same stripped args to runner.py (no selector after --).++ for mode in ["profile", "record"] {++ let helper_cmd = helper_command(++ &ctx,++ "C:\\Python313\\python.exe",++ Path::new("runner.py"),++ mode,++ Path::new("job.json"),++ &cmd[1..],++ );++ let passed: Vec<String> = helper_cmd++ .get_args()++ .skip_while(|a| *a != "--")++ .skip(1)++ .map(|a| a.to_string_lossy().into_owned())++ .collect();++ assert_eq!(passed, want, "{mode} runner args for {cmd:?}");++ }++ }++ let _ = fs::remove_dir_all(&dir);++ }++++ #[test]++ fn py_launcher_scan_and_bench_work_with_version_selectors() {++ if !cfg!(windows) || !Command::new("py").arg("--version").output().is_ok_and(|o| o.status.success()) {++ eprintln!("no Windows py launcher on PATH, skipping");++ return;++ }++ let ver_out = Command::new("py")++ .args(["-c", "import sys; print(f'{sys.version_info[0]}.{sys.version_info[1]}')"])++ .output()++ .unwrap();++ assert!(ver_out.status.success());++ let xy = String::from_utf8_lossy(&ver_out.stdout).trim().to_string();++ let dir = std::env::temp_dir().join(format!("fa-py-launcher-e2e-{}", std::process::id()));++ let _ = fs::remove_dir_all(&dir);++ fs::create_dir_all(&dir).unwrap();++ fs::write(dir.join("work.py"), "def crunch(n: int) -> int:\n return sum(i * i for i in range(n))\n")++ .unwrap();++ fs::write(++ dir.join("app.py"),++ "import sys\nfrom work import crunch\nif __name__ == '__main__':\n\++ \x20 for bad in ('-3', '-V:', '--version:'):\n\++ \x20 assert not any(a.startswith(bad) for a in sys.orig_argv), sys.orig_argv\n\++ \x20 print(sum(crunch(500) for _ in range(50)))\n",++ )++ .unwrap();++ // Verify resolve forwards the selector to py.exe (a nonexistent version must fail instead of falling back).++ assert!(++ resolve("py", &[String::from("-V:fast-anything-nonexistent/3.99"), String::from("app.py")], &dir).is_err(),++ "nonexistent py launcher selector must fail resolve"++ );++ for cmd in [++ vec!["py".into(), "-3".into(), "app.py".into()],++ vec!["py".into(), format!("-{xy}"), "app.py".into()],++ vec!["py".into(), format!("-V:{xy}"), "app.py".into()],++ vec!["py".into(), "app.py".into()],++ vec!["python".into(), "app.py".into()],++ ] {++ crate::pipeline::scan(&dir, cmd.clone(), None).unwrap_or_else(|e| panic!("scan {cmd:?} failed: {e:#}"));++ let ctx = Ctx::open(&dir).unwrap();++ let (_, bench_args) = crate::backend::Lang::Python.bench_command(&ctx).unwrap();++ assert_eq!(bench_args, ["app.py"], "bench args for {cmd:?}");++ let ported = crate::pipeline::port(&dir, Some("work.crunch"), 10)++ .unwrap_or_else(|e| panic!("port {cmd:?} failed: {e:#}"));++ assert_eq!(ported.calls_seen, 50, "recorded calls for {cmd:?}");++ crate::pipeline::bench(&dir, 1).unwrap_or_else(|e| panic!("bench {cmd:?} failed: {e:#}"));++ }++ let _ = fs::remove_dir_all(&dir);++ }++fn port() -> Port {Port {id: "fuzzy.levenshtein".into(),