UHG
Search
Close this search box.

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

Share

Table of Content

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. 

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.

📣 Want to advertise in AIM? Book here

Related Posts
19th - 23rd Aug 2024
Generative AI Crash Course for Non-Techies
Upcoming Large format Conference
Sep 25-27, 2024 | 📍 Bangalore, India
Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.
Flagship Events
Rising 2024 | DE&I in Tech Summit
April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore
Data Engineering Summit 2024
May 30 and 31, 2024 | 📍 Bangalore, India
MachineCon USA 2024
26 July 2024 | 583 Park Avenue, New York
MachineCon GCC Summit 2024
June 28 2024 | 📍Bangalore, India
Cypher USA 2024
Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA
Cypher India 2024
September 25-27, 2024 | 📍Bangalore, India
discord icon
AI Forum for India
Our Discord Community for AI Ecosystem, In collaboration with NVIDIA.