Ruff - The Fast, Rust-based Python Linter
Episode Deep Dive
Guests Introduction and Background
Charlie Marsh is the creator of Ruff, a fast Python linter written in Rust. He previously worked at companies like Khan Academy and Spring Discovery, where he built large-scale Python systems, explored data science topics (including biology-focused computer vision), and experimented with Rust/Python integrations for performance-critical tasks. Out of these experiences grew the motivation to create Ruff, focusing on speed and efficient code analysis.
What to Know If You’re New to Python
Here are a few concepts and terms that appeared in the episode which can help you follow the conversation more easily:
- Linters: Tools that analyze code for errors and style issues.
- Imports and Docstrings: Basic components of Python code structure.
- Configuration Files: For Python projects, you often use
pyproject.toml
or similar files to keep settings consistent. - Command-Line Tools: Tools like Ruff can be installed and run directly via a terminal.
Key Points and Takeaways
- Ruff: A Fast, Rust-based Python Linter Ruff differentiates itself from traditional Python linters by offering significant speed improvements—often over 10x faster than Flake8 or Pylint for large codebases. Its performance stems from using Rust under the hood and a design choice to do only necessary work for each check. This speed enables frequent lint checks (e.g., on file save), making high-quality Python code easier to maintain.
- Links and Tools:
- Motivation and Inspiration from Web Tooling Charlie drew inspiration from JavaScript and TypeScript tooling, which evolved toward languages like Rust and Go to improve speed. He recognized that Python could benefit from a similar approach, leading to the creation of Ruff. The incremental, watch-mode style of other ecosystems’ tools (like TSC’s watch) also influenced Ruff’s
--watch
feature.- Links and Tools:
- Compatibility with Existing Linting Ecosystems Ruff re-implements many popular Flake8, PyDocStyle, and other plugin rules in Rust, preserving configuration approaches so teams can swap in Ruff easily. This practical approach helped the tool achieve quick adoption among projects needing direct parity or minimal configuration changes.
- Links and Tools:
- Adoption by Major Python Projects Important Python libraries such as Pydantic, Pandas, Airflow, and FastAPI have adopted Ruff for rapid feedback and consistency in their codebases. These early adopters also contributed valuable feedback on handling monorepos and advanced configuration, shaping Ruff’s roadmap.
- Focus on Performance and Efficient Parsing Ruff achieves speed not just by using Rust, but also by prioritizing single-pass parsing. It maintains internal data structures that let it check multiple rules at once without repeated work. As a result, developers see near-instant lint results—even in large monorepos.
- Rust + Python Toolchain and Packaging Ruff uses Maturin to build and distribute wheels so developers don’t need to install Rust themselves. This ensures that a
pip install ruff
orpipx install ruff
flows smoothly without manual compilation steps, lowering friction for users.- Links and Tools:
- Powerful Configuration and Auto-Fixes Users can configure Ruff using
pyproject.toml
orruff.toml
to enable or disable specific lint rules. Ruff supports “auto fix” for many items, such as removing unused imports or converting old string formatting to f-strings, simplifying tedious edits.- Links and Tools:
- Black Formatter (often used in combination with Ruff)
- Links and Tools:
- Integration with Editors and Pre-Commit Ruff integrates with common editors like VS Code, PyCharm (via external tooling), Sublime, and Neovim through its language server protocol (LSP) extension. Pre-commit hooks also allow teams to run Ruff checks automatically before commits, ensuring clean code in every push.
- Links and Tools:
- Potential Future Features: Auto-Formatting Charlie envisions expanding Ruff’s functionality beyond lint checks toward full auto-formatting capabilities. While Black remains popular, a built-in formatter could unify code corrections into one step, avoiding multiple tools for style and lint fixes.
- Links and Tools:
- Growing Community and Contribution Opportunities Ruff’s success depends on its active open-source community. Charlie encourages new contributors—even those new to Rust—to jump in with bug reports, features, or doc improvements, highlighting that first-time Rust developers have already made significant contributions.
- Links and Tools:
Interesting Quotes and Stories
- On Ruff’s Roadmap and Speed: “I sort of hate benchmarks because no matter how much time you put into a benchmark, it’s always wrong from a certain perspective. But Ruff is comfortably somewhere between 10 to 100 times faster.”
- On Adopting New Tools: “One issue you see with slow linters is that some people on a team stop running them entirely, and that just pushes their problems onto everyone else. With Ruff, it runs so quickly that you don’t have that friction.”
Key Definitions and Terms
- Linter: A program or tool that analyzes code for syntax errors, potential bugs, and style guideline violations.
- AST (Abstract Syntax Tree): A tree representation of the structure of source code that many linters and code analyzers rely on.
- Plugin Architecture: A design where separate modules, each containing specialized rules or functionality, can be loaded into a core tool.
- Pre-commit Hook: A script or set of commands that run before a commit is finalized, commonly used to enforce code quality or run tests.
Learning Resources
If you want to deepen your Python knowledge and get more comfortable with tools like Ruff, here are some resources from Talk Python Training:
- Python for Absolute Beginners: A comprehensive introduction to Python that starts at step zero, perfect if you’re brand new or want a solid refresher.
Overall Takeaway
Ruff’s explosive adoption shows that fast, developer-friendly tooling can dramatically improve Python projects of every size. By focusing on performance, seamless compatibility, and incremental growth, Ruff has carved out a unique place in the Python ecosystem. Its Rust underpinnings power near-instant lint checks, and its configurable rules provide an easy on-ramp for both small teams and massive open-source projects. With Charlie Marsh actively developing new features and a growing community contributing, Ruff is reshaping how Python developers think about linting—both in speed and in potential beyond just code style checks.
And here's a poem
“Ruff and Ready”
We’ve news to share for me and you:
A linter that’s fast as lightning’s spark—
No half-cooked code left in the dark.
Charlie Marsh arrived on scene,
With Rust in tow—a coding dream!
Flake8 might dawdle, Pylint might stall,
But Ruff says “Millisecond? That’s all!”
No more waiting hours to check your `def`,
No more cursed imports you must stuff.
Hit “save,” watch tests go zippity-zip,
While your CPU’s on a two-second trip.
Some said, “But I love my blackened style!”
Ruff winked: “We can play nice for a while.”
Unused imports? Gone at the snap of a key,
Docstring errors? They’re fixed—so worry-free.
From Pandas to Pydantic, big folks came along,
They said, “Ok Rust-linter, prove you belong.”
Ruff breezed through their code like a comedy act
, No flailing, no fumbling—just well-linted tact.
It’s more than just speed or cunning technique,
It’s bridging together what makes us all geek:
We parse our ASTs, fix that line too long,
And banish old style bugs (like a half-written song).
So raise your coffee cups, dear developer friend,
And toast to a tool that might never quite end—
For open-source hearts keep the dream afloat,
With watchers and watchers on GitHub they vote.
Here’s to Charlie and Rust, in Python’s domain,
A cross-language quest that’s far from plain.
We’ll lint, auto-fix, maybe even auto-format soon,
Dancing with code by the glow of the moon.
So code on bravely, no matter the chore,
Ruff stands behind you, leveling the score.
In this geeky sonnet of checks and might,
May all your Python bugs say “Goodnight!”
Links from the show
Charlie on Mastodon: @charliermarsh@hachyderm
Ruff: github.com
PyCharm Developer Advocate Job: jetbrains.com/careers
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm
--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy