Sitemap

Member-only story

Build a Fast File Search Tool: Rust vs. Python

I built two command-line search tools to explore how file traversal, streaming, and pattern matching affect performance — and when Rust’s extra complexity is worth it.

11 min read5 days ago

--

Press enter or click to view image in full size

Searching for text inside files is one of those tasks that looks trivial until the directory gets large.

You might need to find every occurrence of a configuration key across a repository, locate an error message in application logs, or search hundreds of thousands of lines for a particular pattern.

A quick Python script can solve the problem in a few minutes. Rust can solve it too, with a compiled executable and explicit control over how files are processed.

But which approach is better when the input grows?

Rather than compare language features in isolation, let’s build the same command-line utility in both languages. It will recursively search a directory for a phrase or regular expression, print matching file paths and line numbers, and process files incrementally.

We’ll then examine the engineering trade-offs and set up a fair benchmark.

One important distinction: this article provides runnable implementations and a benchmark method…

--

--

Yorn Rothy
Yorn Rothy

Written by Yorn Rothy

Software developer and tech enthusiast writing about coding, testing, automation, and the real journey of becoming a better engineer.