I Converted 10 Python Scripts to Rust — Here’s How They Compared
From simplicity to speed — a developer’s journey translating Python logic into Rust power

I love Python — but when speed and memory started to matter, I turned to Rust. What I found surprised me.
I Converted 10 Python Scripts to Rust — Here’s How They Compared
When I first learned Python, I fell in love with its simplicity.
It reads like English, lets you build fast prototypes, and has a library for almost everything.
But when performance and system-level control started to matter more in my projects, I kept hearing the same name: Rust.
Curious (and slightly skeptical), I took 10 of my frequently used Python scripts and rewrote them in Rust.
The goal? To see what I’d gain — or lose — in the transition.
This post is a breakdown of that experience: performance, readability, development time, bugs, and more.
The Test Subjects: What I Converted
Here are the 10 Python scripts I chose:
- File Organizer — Automatically sorts files into folders by extension.
- CSV Analyzer — Reads large CSV files and outputs summary statistics.
- Markdown to HTML Converter — Converts
.md
files to HTML using a template. - Simple Web Crawler — Fetches and logs links from a list of URLs.
- Image Resizer — Batch resizes JPEG and PNG images.
- Password Generator — Creates secure random passwords.
- Todo CLI App — A basic terminal-based task manager.
- JSON Cleaner — Recursively removes null/empty values from nested JSON.
- Log Parser — Parses server logs and generates usage reports.
- Port Scanner — Scans IP addresses for open ports in a given range.
Performance: Rust Was a Beast
No surprises here — Rust outperformed Python in nearly every task that involved I/O or computation. The most dramatic gains were:
| Script | Python Time | Rust Time | Speedup |
| ------------------------- | ----------- | --------- | ------- |
| CSV Analyzer (100MB) | 5.8s | 0.9s | \~6.4× |
| Web Crawler (100 URLs) | 11.3s | 2.1s | \~5.3× |
| Image Resizer (50 images) | 6.7s | 1.4s | \~4.8× |
| Port Scanner | 12.4s | 1.6s | \~7.7× |
Rust’s zero-cost abstractions and safe concurrency make it unbeatable when every millisecond counts. Python’s GIL (Global Interpreter Lock) was a major bottleneck, especially for multithreaded tasks.
Developer Experience: Python Still Wins on Speed (of Writing)
Here’s how development time compared, on average:
- Python: 30–90 minutes per script
- Rust: 2–4 hours per script (excluding setup time)
Writing in Rust forced me to think harder. The compiler caught things I didn’t even realize could go wrong — from lifetimes and memory safety to thread safety. It was frustrating at times, but I slowly grew to appreciate the strictness.
With Python, I could move fast and break things. With Rust, I moved slower — but broke almost nothing.
Bugs: The Compiler is Your Friend (and Foe)
Some of my Python scripts had hidden bugs I never noticed:
- The JSON Cleaner didn’t handle circular references well.
- The Port Scanner occasionally missed open ports due to bad timeout logic.
- The Web Crawler sometimes crashed on malformed URLs.
In Rust, none of these bugs made it through compilation. The compiler nagged me constantly until I wrote safer, more robust code. It was annoying — but incredibly reassuring.
If Python is your friendly barista who hands you coffee fast, Rust is the grumpy librarian who makes sure your thesis is flawless before you leave.
Learning Curve: Steep, But Worth It
Rust has a steep learning curve, especially if you’re coming from dynamic languages like Python. Concepts like ownership, borrowing, lifetimes, and traits can take time to digest.
Here’s what helped me climb the curve:
- Rustlings: Interactive exercises to learn syntax and concepts.
- The Rust Book: Arguably the best programming book ever written.
- Real-world projects — nothing teaches better than building.
After converting 10 scripts, I started feeling at home with Rust’s syntax and mindset. The pain faded. The joy of control remained.
Ecosystem & Tooling: Surprisingly Mature
Python’s ecosystem is vast, but Rust’s is no slouch. The cargo
tool is a joy — think pip
, virtualenv
, and pytest
all rolled into one.
Libraries I used:
serde
– for JSON parsing (better thanjson
in Python).reqwest
– for HTTP requests (similar torequests
).image
– for image manipulation.clap
– for building command-line interfaces.rayon
– for data parallelism (zero effort threading).
Most tasks had solid crates available, though occasionally, I had to dig deeper into docs or handle edge cases manually.
Summary: Tradeoffs Worth Making
| ------------------------ -------------------------------------
| Category | Winner |
| ------------------------ | ------------------------------------- |
| Performance | Rust |
| Ease of Writing | Python |
| Safety & Robustness | Rust |
| Ecosystem | Python (by volume), Rust (by quality) |
| Tooling | Rust (thanks to `cargo`) |
| Prototyping | Python |
| Production Readiness | Rust |
------------------------ -------------------------------------
Final Thoughts: What I’ll Use Going Forward
Will I abandon Python? Absolutely not.
But when I need raw performance, multithreading, or system-level control — I’m reaching for Rust.
Here’s how I now think:
- Quick Script? Use Python.
- Mission-Critical CLI Tool or Daemon? Use Rust.
- Web API? Depends — I might prototype in Python (FastAPI), then rewrite in Rust (Axum or Actix).
- Anything that runs in prod 24/7? Rust. Fewer bugs. Lower CPU. Less memory. Peace of mind.
Over to You
Have you tried rewriting Python code in Rust? What was your experience like? I’d love to hear what surprised or frustrated you most.
If you enjoyed this post, follow me for more deep dives into Python, Rust, and real-world software adventures.
