fast-anything: Python to Rust vs Plain Claude Code

fast-anything: Python to Rust vs Plain Claude Code

On Hacker News, somebody asked why you would need a tool like fast-anything when you can just tell your coding agent to rewrite the slow part in Rust. I wanted to know that too, so I tried both.

In this post, I show you how to set up fast-anything, run its own example, port one NLTK function to Rust, and then give plain Claude Code the same job.

My Python script took about 10 seconds before. The tool got it down to 0.11 seconds, and Claude alone got it to 0.13 and 0.14 seconds on the same model with the same effort.

Like the video? Subscribe on YouTube for the next one.

Table of Contents

fast-anything Quick Start

You need Python, Node.js with npm, git and a working Claude Code install. Then install Rust and pick the default option:

Terminalbash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
. "$HOME/.cargo/env"
cargo --version

Now install the tool and let it check your machine:

Terminalbash
npm i -g @el4cteo/fast-anything
fast-anything --version
fast-anything doctor

The short way is one command. It does everything from the scan to the final benchmark, and it switches the Rust version on once the checks pass. This is the run from the tool’s own example:

Terminalbash
fast-anything go --agent claude -- python3 app.py

The step by step way gives you a chance to stop after each step. These are the commands from my NLTK test:

Terminalbash
fast-anything scan -- python fuzzy_dedupe.py
fast-anything port --agent claude
fast-anything verify
fast-anything enable && fast-anything bench

To run the original Python once, or to take the change out again:

Terminalbash
FAST_ANYTHING_DISABLE=1 python fuzzy_dedupe.py
fast-anything disable nltk.metrics.distance.edit_distance && git status --short

Make sure your own project is committed before you start. The tool changes your Python file when it switches the Rust version on, and a clean git status makes that easy to see.

Install and Setup

This is what I tested with, on a Mac with Apple silicon:

  • Python 3.14.6 and Node.js 26.12.1
  • cargo 1.100.1
  • fast-anything 0.9.0
  • Claude Code 2.1.332
  • NLTK 3.10.4, installed from a clone of its repo

I don’t go through the Python, Node.js and Claude Code installs here. The video doesn’t show them either.

The screenshots are frames from the video. The big captions and the orange boxes come from the edit, not from the tools, and I blurred the private part of my paths.

Install Rust with rustup

The new code is written in Rust, so we need that first. rustup is the official Rust installer, and this is the command from its home page:

Terminalbash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

The installer shows you its defaults and asks what to do. I went with option 1, the standard installation, so you can just press Enter.

On my very first try, the same terminal tab couldn’t find cargo afterwards. This line loads it into the tab you already have open:

Terminalbash
. "$HOME/.cargo/env"

Make sure to type the dot and the space at the beginning. Now check that cargo is there:

Terminalbash
cargo --version

I got this:

Terminalbash
cargo 1.100.1 (3acc79c0c 2026-11-05)

Install fast-anything with npm

fast-anything is an open source command line tool with an MIT license. It’s one npm install:

Terminalbash
npm i -g @el4cteo/fast-anything

The line in the README also ends with the comment # or: cargo install fast-anything. I pasted that along with the command. Copy only the part before the #, because not every shell treats it as a comment when you paste it.

Let’s check the version:

Terminalbash
fast-anything --version

Mine is 0.9.0. The GitHub repo was already on 0.9.1 when I recorded this, so compare your version before you compare your output.

Check your machine with fast-anything doctor

Now let the tool check if everything it needs is there:

Terminalbash
fast-anything doctor
fast-anything doctor output with check marks for cargo, Python and Node.js

As you can see, it found cargo and Python. Claude Code comes further down in the list, and these are the lines we want to see:

Snippettext
✓ claude 2.1.332 (Claude Code)
✓ ready to scan
✓ ready to port

It also lists things like Java and Go as not found. Those are for apps in other languages, so we don’t need them here.

What fast-anything Does

fast-anything finds the functions that take the most time, and your coding agent rewrites only those in Rust. The rest of your app stays as it is.

While your app runs, the tool records real calls to the slow function. It then runs the Rust version on those calls and compares the results with Python.

According to its README, it records up to 500 real calls and adds edge cases. Every 5th call is hidden from the agent, and nothing gets switched on until every case matches.

The README also says that a Rust version that is slower per call stays off. I didn’t run into that one.

It supports a bunch of other languages too, but I only tested it with Python.

Run the fast-anything Example

The repo comes with a small example that looks for almost identical names. It’s a good first run, because you don’t touch your own code.

Clone the repo and time plain Python

First we make a folder and clone the repo. I used ~/Development/YouTube/fast-anything-demo, but you can use any folder as long as you change it in every command:

Terminalbash
mkdir -p ~/Development/YouTube/fast-anything-demo && cd ~/Development/YouTube/fast-anything-demo && git clone --depth 1 https://github.com/EL4CTEO/fast-anything.git

Now go into the example and time it in plain Python:

Terminalbash
cd fast-anything/examples/fuzzy-dedupe && time python3 app.py

It found 822 likely duplicate pairs in 700 names, and it took about 1.88 seconds on my Mac:

Terminalbash
python3 app.py  1.82s user 0.05s system 99% cpu 1.878 total

Run scan, port, checks and benchmark with go

With go, one command does the whole job. --agent claude picks Claude Code as the agent, and everything after -- is the command that starts your app:

Terminalbash
fast-anything go --agent claude -- python3 app.py

The whole run took 2 minutes and 12 seconds. Most of that was Claude writing the Rust version, and you don’t see much happening while he works.

fast-anything benchmark of its own example: 1.87 s in Python, 18 ms in Rust, 106x faster

In the tool’s own benchmark, the example went from 1.87 seconds to 18 milliseconds. That’s 106 times faster as the median of 5 rounds.

It’s also their own example, so don’t expect that everywhere.

The check before the benchmark matters more to me:

Snippettext
✓ 33/33 calls give the same result (1 recorded + 7 edge cases + 25 derived)

All 33 checks gave the same result. But the script only makes one call to that function, so just one of them was a real recorded call and the tool came up with the other 32.

See what changed in the Python file

Let’s look at what the tool did to the code:

Terminalbash
git status --short && git diff fuzzy.py

Only fuzzy.py changed. The tool added a block that loads the Rust version, and it starts like this:

pythonpython
# >>> fast-anything: fuzzy.find_duplicates >>>
# Uses the verified Rust port. FAST_ANYTHING_DISABLE=1 runs the Python above instead.
# Undo with:  fast-anything disable fuzzy.find_duplicates
def _fast_anything_load():
    import os, sys
    if os.environ.get("FAST_ANYTHING_DISABLE"):

The original Python is still above it, and the off switch is right there in the comment. My recording stops at that last line, so this is not the whole block.

Now run the example again:

Terminalbash
time python3 app.py

I got the same 822 pairs and the same five example pairs on the screen. This time, it took 0.024 seconds in total.

Check Which Model Writes the Rust

I wanted to know which model the tool uses, because a comparison with plain Claude Code is only fair on the same one. So I searched its source code from a second terminal tab, after the run:

Terminalbash
cd ~/Development/YouTube/fast-anything-demo/fast-anything && grep -n -A6 '"claude" =>' src/agent.rs

This is what it prints:

Snippettext
12:        "claude" => &[
13-            "claude",
14-            "-p",
15-            "--permission-mode",
16-            "acceptEdits",
17-            "--allowedTools",
18-            "Read Edit Write Glob Grep Bash(cargo check:*) Bash(cargo build:*) Bash(cargo test:*) Bash(cargo fmt:*)",

There is no --model in there. Keep in mind that this is the 0.9.1 source and I ran 0.9.0.

The output also stops before the closing bracket. In the file, that bracket is the next line, so no --model follows.

My Claude Code session logs show Fable 5.2 at medium effort for both of the tool’s runs, the example and NLTK. That part only comes from the logs. You can’t see it in the tool’s output.

If your Claude Code uses another model or effort, keep that in mind when you compare your times with mine.

Test fast-anything on NLTK edit_distance

For the real test, I used NLTK, the Natural Language Toolkit for Python. Its edit_distance function counts how many letters you have to change, add or remove to turn one word into another.

Clone NLTK and create the virtual environment

We clone NLTK, create a virtual environment and install NLTK from the clone. With -e, Python uses the files in this folder, so a change in there counts right away:

Terminalbash
cd ~/Development/YouTube/fast-anything-demo && git clone --depth 1 https://github.com/nltk/nltk.git nltk-tool && cd nltk-tool && python3 -m venv .venv && source .venv/bin/activate && pip install -e .

You end up in the nltk-tool folder with the virtual environment active. Stay in this tab for all the steps with the tool.

This clones the current version of NLTK. All my NLTK clones were at commit 0ed5528.

Create the benchmark script

My script takes 1500 dictionary words and compares every pair. Paste this whole block into the terminal, and it creates fuzzy_dedupe.py:

Terminalbash
cat > fuzzy_dedupe.py <<'EOF'
"""Fuzzy dedupe benchmark: every pair of N dictionary words through NLTK's edit_distance."""
import sys
import time

from nltk.metrics.distance import edit_distance

N = int(sys.argv[1]) if len(sys.argv) > 1 else 1500
WORDS = open("/usr/share/dict/words").read().split()[100000:100000 + N]

start = time.perf_counter()
pairs = 0
close = []
for i, a in enumerate(WORDS):
    for b in WORDS[i + 1:]:
        pairs += 1
        if edit_distance(a, b) <= 2:
            close.append((a, b))
seconds = time.perf_counter() - start

print(f"{len(WORDS)} words, {pairs} pairs compared")
print(f"{len(close)} near-duplicates, e.g. {close[:3]}")
print(f"{seconds:.2f} s")
EOF

Make sure /usr/share/dict/words exists on your machine, because the script reads its words from there. With a different word list, your number of near-duplicates will be different too.

The time it prints covers only the loop over the pairs. Starting Python and loading NLTK are not part of it, and that will be important for the result.

Now run it in plain Python:

Terminalbash
python fuzzy_dedupe.py
Snippettext
1500 words, 1124250 pairs compared
5361 near-duplicates, e.g. [('jettage', 'jetware'), ('jetted', 'jetter'), ('jetted', 'jettied')]
10.15 s

So that’s more than 1.1 million calls, 5361 near-duplicates and 10.15 seconds.

Find the slow function with scan

The scan runs your script under a profiler and ranks the functions by time. It doesn’t port anything yet:

Terminalbash
fast-anything scan -- python fuzzy_dedupe.py
fast-anything scan of the NLTK script with edit_distance first at 97.8% and the verdict port it

As you can see, edit_distance is right at the top with 97.8% of the time and the verdict “port it”. The helper functions it calls get ported together with it.

The scan took 22 seconds. The script runs slower under the profiler, so don’t use that time as your baseline.

The table is wide, and it wraps in a narrow terminal like mine. Make your window wider before you run the scan.

Port the function to Rust

Now we let Claude write the Rust version:

Terminalbash
fast-anything port --agent claude

The tool recorded 500 real calls out of 1,124,250, and Claude wrote the Rust version from there. The command took 2 minutes and 21 seconds, and the first attempt passed.

fast-anything port result: 800 of 800 calls give the same result after 2m21s

The tool also keeps its files for each port. Let’s list them:

Terminalbash
ls .fast/ports/*/

You should see the Rust project, the recorded calls, a TASK.md and an agent.log. The log has Claude’s own note about his work:

Terminalbash
cat .fast/ports/*/agent.log

He says the port compiles but is not verified. The permission mode blocked the verify command and his own comparison script.

Check the 800 calls

The tool runs that check itself, and it already did that during port. We can run it again at any time:

Terminalbash
fast-anything verify
Snippettext
✓ 800/800 calls give the same result (400 recorded + 100 held out + 100 edge cases + 200 derived)

All 800 calls gave the same result:

  • 400 were recorded calls.
  • Another 100 were recorded too, but kept hidden from Claude.
  • The last 300 were 100 edge cases and 200 calls the tool derived.

This doesn’t compare all 1.1 million pairs, and it’s not proof for every possible input.

Switch it on and run the benchmark

Once all the calls match, we can switch the Rust version on and time the whole program:

Terminalbash
fast-anything enable && fast-anything bench
fast-anything bench for the whole NLTK program: 10.28 s in Python, 270 ms in Rust, 38x faster, with a warning about the output

The whole program went from 10.28 seconds to 270 milliseconds, and that’s 38 times faster. Both commands together took 1 minute and 54 seconds.

This benchmark also counts starting up Python. Don’t compare its 270 milliseconds with the times the script prints.

The benchmark also warned me that it couldn’t compare the program’s output, because the output changes from run to run. My script prints its own time at the end, so I think that’s what changes, but the tool doesn’t say.

You can see what the tool changed in NLTK with this command:

Terminalbash
git status --short && git diff nltk/metrics/distance.py
Snippettext
 M nltk/metrics/distance.py
?? .fast/
?? fuzzy_dedupe.py

It’s the same kind of block as in the example, at the end of nltk/metrics/distance.py.

Time the finished version twice

For the comparison later, we only use the time from the script. With the Rust version still switched on, run it twice:

Terminalbash
python fuzzy_dedupe.py; python fuzzy_dedupe.py

I got 0.11 seconds both times, with 5361 near-duplicates in both runs.

Switch the Rust Version Off Again

There are two ways to go back. The first one runs the original Python for one run and changes nothing in the files:

Terminalbash
FAST_ANYTHING_DISABLE=1 python fuzzy_dedupe.py

That took 10.25 seconds and found the same 5361 near-duplicates, so we’re back to the old speed.

The second way takes the change out of NLTK’s file completely:

Terminalbash
fast-anything disable nltk.metrics.distance.edit_distance && git status --short
fast-anything disable puts NLTK edit_distance back to the original code and git status no longer lists distance.py

As you can see, git no longer lists distance.py as changed. The .fast/ folder and the benchmark script are still there.

Make sure you did the two timing runs before you run disable. After that, the script runs in plain Python again.

Give Plain Claude Code the Same Job

Can plain Claude Code do this without the tool? To be honest, my first comparison wasn’t a fair one.

The tool had used Fable 5.2 at medium effort, but plain Claude ran on Opus 5.5 at high effort. I had switched the model with /model opus before I sent the prompt, and the mismatch only came up in the logs afterwards.

So I recorded plain Claude again on Fable 5.2 at medium effort. Everything in this section is from that second run.

Set up a fresh copy of NLTK

Open a new terminal tab, so you don’t mix up the two versions. Then clone NLTK again and copy the script over:

Terminalbash
cd ~/Development/YouTube/fast-anything-demo && git clone --depth 1 https://github.com/nltk/nltk.git nltk-claude-fable && cp nltk-tool/fuzzy_dedupe.py nltk-claude-fable/ && cd nltk-claude-fable && python3 -m venv .venv && source .venv/bin/activate && pip install -e .

Run the plain Python version here too:

Terminalbash
python fuzzy_dedupe.py

It took 10.10 seconds this time, with the same 5361 near-duplicates.

Set the model and effort in the command

Now start Claude Code with both set right in the command:

Terminalbash
claude --model fable --effort medium
Claude Code start command for the fast-anything comparison with the model set to fable and the effort to medium

Both flags are in the official Claude Code CLI reference. Claude Code asks if you trust the folder, and once you confirm, it shows “Fable 5.2 with medium effort” at the top. Mine was in auto mode, and Claude didn’t ask me anything during the run.

Let Claude profile, port and test

I gave him one prompt. You can copy it from the Prompts section below.

Claude found the same function, set up the Rust project and installed the build tool, maturin, by himself. His first test run came back with errors, so he installed the missing test package, pytest-mock, and ran the tests again.

He was done after 2 minutes and 42 seconds. You can’t compare that with the 2 minutes and 21 seconds of the tool’s port command, because the two cover different work.

Claude Code report for its Rust version of edit_distance: all 15 tests pass, one compares 1,124,250 pairs

This is what his report says:

  • All 15 new tests pass. One of them compares all 1,124,250 pairs from my script with the original Python.
  • The existing distance and metrics tests still pass, with 83 passed and 1 skipped.
  • Inputs his Rust version doesn’t handle itself, like token lists or float costs, go through the original Python.

Those are his own tests and his own report. I didn’t run them again myself.

Now leave Claude Code. I typed exit:

Terminalbash
exit

Back in the shell, run the finished version twice:

Terminalbash
python fuzzy_dedupe.py; python fuzzy_dedupe.py

I got 0.13 seconds and then 0.14 seconds. Both runs found the same 5361 near-duplicates.

fast-anything vs Claude Code: The Result

I only compare the times my own script prints. These are the two finished versions, two runs each:

Version Model and effort Run 1 Run 2 Near-duplicates
fast-anything 0.9.0 Fable 5.2, medium (from the session logs) 0.11 s 0.11 s 5361 in both
Claude Code alone Fable 5.2, medium (set in the command) 0.13 s 0.14 s 5361 in both
Screen recordings of the fast-anything and Claude Code runs: 0.11 s twice, then 0.13 s and 0.14 s, with 5361 near-duplicates each time

The gap is 0.02 to 0.03 seconds, on a script that took about 10 seconds before. I don’t call a winner here.

The earlier run on Opus 5.5 at high effort is just an extra. It took 0.18 seconds in all four runs and also found 5361 near-duplicates each time. Its model and its effort were both different, so it doesn’t tell us which model is better.

What this test doesn’t show

  • There is only one Rust version per side. The two runs time the same finished version twice. If you let each side write its version again, you can get other times.
  • I recorded the two sides a day apart. The tool’s runs are from November 29 and Claude’s are from November 30, and I didn’t time the tool’s version again on the second day. I can’t tell you why it was a bit faster.
  • The instructions weren’t the same. The tool gives Claude its own task and limits what he’s allowed to run. Plain Claude got my prompt and ran in auto mode.
  • It’s one benchmark, and it’s the tool’s home turf. Almost all the time is in one function, and it’s the same kind of job as the tool’s own example.
  • I only tested short words. With a lot more data per call, the result can be different.
  • The same count is not a full output check. Every run found 5361 near-duplicates and showed the same three examples, but I didn’t compare the full lists of those runs.

Three Doubts From Hacker News

The Hacker News thread has three doubts that I wanted to check.

You can just ask your agent

This comment says you don’t need a repo for this, because you can ask your agent to find the bottleneck and rewrite it in Rust.

In my test, that really worked. But my prompt did ask for the profiling and for the test that compares the results.

Amdahl’s law limits the gain

This one brings up Amdahl’s law. It basically means that speeding up one function won’t help much if it’s only a small part of the total time.

My test is close to the best case for this tool. If your app is slow in lots of small places, like another comment describes, you’ll get a lot less out of it.

The scan gives you a good idea of that before you change anything. If no function takes a big part of the time, you can stop right there.

Calls from Python to Rust cost time

Each call from Python to Rust has an extra cost, and this comment says it often eats up the gains.

My script makes more than 1.1 million of those calls and still went from about 10 seconds to 0.11. So here, it wasn’t a dealbreaker, at least with short words.

The tool’s own example is different. There, it ported the function with the loop inside, so the script makes just one call.

Verdict: Built-in Checks or Your Own Prompt

Speed alone isn’t a reason to pick fast-anything here. The built-in checks and the off switch are.

The tool tests the Rust version on real calls, keeps some of them hidden from Claude and lets you go back with one command. Those 800 calls still aren’t proof for every possible input.

Claude’s test covered every pair in my script. But he wrote and ran that test himself, and I had to ask for it.

If you know what to ask for and how you want it tested, plain Claude Code can do this job well. If you’d rather have those checks built in, fast-anything is a pretty cool tool.

Prompts

The prompt for plain Claude Code (05:34 in the video)

This is the only prompt I gave Claude in the run without the tool:

Snippettext
fuzzy_dedupe.py in this repo is slow. Profile it, find the hot function and rewrite only that function in Rust, so that `python fuzzy_dedupe.py` gets faster. Don't use the fast-anything tool. Keep the Python API and the script's output exactly the same, and prove it with a test that compares the Rust version against the original Python on real inputs. At the end tell me the time before and after.

The earlier Opus 5.5 run at high effort got exactly the same prompt.

For your own project, change the file name and the command. Keep the part about the test, because that’s what you have to ask for yourself.

I didn’t write a prompt for fast-anything. The tool puts its own instructions for Claude in the TASK.md file of each port.

Gotchas

  • You can get a newer version than mine. I ran 0.9.0, and the repo was already on 0.9.1. Run fast-anything --version first when your output looks different.
  • The virtual environment is only active in its own tab. If you open another one, go into the right NLTK folder and run source .venv/bin/activate again.
  • Claude’s note says “not verified”. Claude couldn’t run the check himself, but the tool did that right after. Look for the 800/800 line, or run fast-anything verify again.
  • The benchmark can’t compare your output. That happens when a program prints something different in every run. You then only have the replayed calls as a check, so compare the important part of your output yourself.
  • Claude leaves his changes uncommitted. His report says that nothing is committed, so look at the diff before you keep anything.

Your Turn

You now have every command from my test, so you can run the scan on your own project first. It doesn’t port anything, and it shows you if one function takes most of the time.

What is the slowest part of your Python code, and would you let Claude rewrite it in Rust? Let me know on X @StefanRows or in the comments under the YouTube video.

whoami

I'm Stefan, a senior software engineer. I build with AI agents every day, and I show how: my workflows, the new tools I test and what breaks along the way. I build apps like XPmetric and ProofSwap, and my own tooling too, like the AI Coding Orchestrator and the pipeline that edits my videos. I started in 2016 with Linux, cybersecurity and Python tutorials. Then AI changed how I work, so the videos changed too. Still a Linux nerd at heart.

More about me