Google Adopts Pyrefly for Faster, More Accurate Python Type Checking
Google has replaced its long-standing Python type checker, Pytype, with Pyrefly, an open-source tool originally developed by Meta. The decision was driven by Pyrefly's advantages, including faster and more accurate type checking, and lower infrastructure costs. By Sergio De Simone
Google has replaced its current Python type checker, Pytype, with Pyrefly, an open-source tool originally developed by Meta. This shift was motivated by Pyrefly's advantages, such as faster and more precise type checking, as well as reduced infrastructure costs. As Python's typing system has rapidly evolved, Pytype struggled to keep up due to its analysis of compiled bytecode, which led to frequent maintenance issues when new Python PEPs were introduced.
Google's internal testing revealed that Pyrefly is around 10 times faster than Pytype, cuts incremental rebuild latency by up to 98%, and lowers peak compute cost for Python type checking by over 80%. Additionally, Pyrefly's performance is 90-99% quicker than Pytype within clean-build critical paths, effectively eliminating a longstanding development bottleneck.
One of Pyrefly's standout features is its strong compliance with Python's typing specification, passing close to 97% of conformance suite tests. The tool also benefits from strong community support, ensuring it stays updated with new syntax and provides more actionable feedback, including inline code annotations that pinpoint error causes and even suggest fixes.
The developer community welcomed Google's announcement, although some debate exists regarding Pyrefly's relative merits compared to Ty and Mypy. Pyrefly is also more mature, having reached a 1.0 version and offering performance comparable to Ty while being a tested tool. While Mypy is faster in large setups, its incremental type check speed still lags behind Pyrefly's capabilities.
A Python developer on LinkedIn expressed a different viewpoint, stating that a type-checker's value extends beyond merely speeding up CI pipelines to improving the edit-check loop during development. He advised evaluating Pyright, Pyrefly, and Mypy based on cold and warm times on an individual's project and considering diagnostics quality alongside throughput.
Meta open-sourced Pyrefly last year, implementing it in Rust for maximum efficiency. According to Meta, Pyrefly can check 1.8 million lines of code per second on large codebases, enabling typechecking on every keystroke.
Written by urgent.news from InfoQ's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.