This Rust-based Python Linting Tool is Quick as Lightning

Marsh’s need to make Ruff was born out of his own frustrations with tools in the Python ecosystem

Code quality tools like linters and test frameworks are an important bit of the machine for developers. Linters play the part of keeping the code error free and ensure that it conforms to the rules implemented in the team. Conversely, when these tools are slow and sluggish, they can slow down development to a great degree. A new tool from this space called Ruff has been making noise in the community of late. 

Comparative study in speed between Ruff and other linting tools

Origin of Ruff

Charlie Marsh, a Khan Academy alum released the tool last year on August 30 but in the five months that have gone by, Ruff has gained a lot of ground. Marsh admits that Ruff’s sudden popularity has taken him by surprise, and that is why he called it ‘Ruff’ (rough). “I don’t consider it production-ready, it’s only a proof-of-concept,” he said on a thread posted on Hacker News

Last month, Marsh wrote a blog post discussing where he wanted to take Ruff in the future. ‘I meant to write this post after the first 100 releases, but now (v0.0.226) seems as good a time as any to recap the progress we’ve made over the last few months, and share more on where we’re headed,’ he stated. 

Need for speed in Python tools

Marsh’s need to make Ruff was born out of his own frustrations with tools in the Python ecosystem. JavaScript has been on the beneficial side as its tools have evolved and grown faster with time. Since projects have become heavier and more complicated, new packages emerged based on languages which were faster and consumed lesser energy. 

Marsh calls this the ‘Rustification’ of the JavaScript toolkit. A bunch of these new tools are all built on new programming languages like SWC and Rome are built on Rust, esbuild is built on Go and Bun is built on Zig. 

And there’s good reason to have more Rust-based tools. Karthik Devaraj, a full-stack developer with MachineHack explains, “While Rust is an object-oriented language like C++, it combines less energy consumption with faster speed. Earlier, it used to take me around 21 seconds, but once I switched to the Rust-based SWC, it took me between 2 to 3 seconds.” 

Marsh felt that the Python environment too could gain from similar faster tools. Ruff has been found to be over 150X faster than Flake8, a popular Python lint wrapper; 75X faster than pycodestyle, the official linter to check Python for the PEP8 Python style; and 50X faster than pylint. 

Why is it popular?

Ruff now has become the primary linter for some of the most important Python-based projects like Pandas, FastAPI, Apache Airflow and Jupyter on GitHub even as it gets high praise from the community. 

A developer listed the advantages of Ruff – “I love Ruff. These are reasons it ended up being better than simply touching a ‘standard of excellence’. First off, it has a second-mover advantage. It has learned from all the existing tools. Secondly, it is deduplicated work which means it pretty much is a ‘do everything’ and does it all at once. (Using three separate linters meeting different needs would mean it parses through the code three times). And thirdly, Rust is faster than Python.” 

Just yesterday, Marsh tweeted the happy news that open-source platform Hugging Face had adopted Ruff already. Sayak Paul, a developer at the company spoke about the tool saying, “It’s bloody fast and actually takes actions instead of just plain erroring out that you didn’t use a particular import.” 

Sylvain Gugger, a senior ML engineer at the company, in fact, lauded Marsh saying, “Thank you so much for writing Ruff! With Transformers having so many files, you’re saving us a loooooot [sic] of time on formatting.” 

Marsh, however, has always been transparent about what he thinks are Ruff’s limitations, “It supports only a small set of rules till now and isn’t extensible in any way, it’s missing edge-case handling and is significantly under-tested compared to existing tools.” 

Since then Marsh has worked on improving the tool. There’s an official VS Code extension released to support Quick Fix actions to autofix lint errors, flake8-to-ruff which automates migration from Flake8 to Ruff as well as Conda and Homebrew distributions for easy installation of the tool.

Download our Mobile App

Poulomi Chatterjee
Poulomi is a Technology Journalist with Analytics India Magazine. Her fascination with tech and eagerness to dive into new areas led her to the dynamic world of AI and data analytics.

Subscribe to our newsletter

Join our editors every weekday evening as they steer you through the most significant news of the day.
Your newsletter subscriptions are subject to AIM Privacy Policy and Terms and Conditions.

Our Recent Stories

Our Upcoming Events

3 Ways to Join our Community

Telegram group

Discover special offers, top stories, upcoming events, and more.

Discord Server

Stay Connected with a larger ecosystem of data science and ML Professionals

Subscribe to our Daily newsletter

Get our daily awesome stories & videos in your inbox

Can OpenAI Save SoftBank? 

After a tumultuous investment spree with significant losses, will SoftBank’s plans to invest in OpenAI and other AI companies provide the boost it needs?

Oracle’s Grand Multicloud Gamble

“Cloud Should be Open,” says Larry at Oracle CloudWorld 2023, Las Vegas, recollecting his discussions with Microsoft chief Satya Nadella last week. 

How Generative AI is Revolutionising Data Science Tools

How Generative AI is Revolutionising Data Science Tools

Einblick Prompt enables users to create complete data workflows using natural language, accelerating various stages of data science and analytics. Einblick has effectively combined the capabilities of a Jupyter notebook with the user-friendliness of ChatGPT.