🛒 Arduino, ESP32 & modules
Google Replaces Pytype with Meta’s Pyrefly for Python Type Checking
44 MIN AGOProgramming

Google Replaces Pytype with Meta’s Pyrefly for Python Type Checking

Google has adopted Meta’s Rust-based Pyrefly as its main Python type checker, reporting 10x speedups, >80% compute savings and stricter, clearer diagnostics across its monorepo.

October 19, 20263 min read5 tags

Google has officially switched its primary Python type checker from the long‑standing in‑house Pytype to Pyrefly, an open-source tool originally developed by Meta. The change affects hundreds of thousands of Python files in Google’s monorepo and is aimed at improving both performance and type safety.

Why move away from Pytype?

For over a decade, Pytype was Google’s main static type checker and helped bootstrap the typeshed ecosystem. But the tool’s architecture started to show its age as Python’s typing system evolved:

  • Pytype analyzes compiled bytecode instead of source ASTs
  • Bytecode instability across Python releases made tracking new typing PEPs expensive
  • It struggled to deliver the low latencies expected in modern edit–check–build loops

Google has now frozen Pytype at Python 3.12 support and evaluated modern open-source alternatives, ultimately standardizing on Pyrefly.

What makes Pyrefly attractive?

Pyrefly is written in Rust and designed for high throughput with lazy, parallel evaluation. According to Google’s internal benchmarks:

  • Roughly 10× faster than Pytype
  • Up to 98% lower incremental rebuild latency
  • 90–99% reduction of type-checking time on clean-build critical paths
  • More than 80% lower peak compute usage for Python type checking

On the language side, Pyrefly:

  • Scores about 97% on the official typing conformance test suite
  • Is actively kept in sync with new Python versions and typing PEPs
  • Enforces sound union checking, rejecting unsafe calls like passing int | None to a function expecting int

Diagnostics are another major upgrade: Pyrefly emits Rust-style compiler messages with inline code snippets, precise highlights, and often suggested fixes, making subtle typing bugs easier to track down.

Community reaction and practical advice

The announcement sparked discussion around how Pyrefly compares to Mypy, Pyright, and Ty. Some engineers note that Mypy 2.0 can be up to 5× faster on large cold checks, while others point out that newer checkers like Pyrefly still reach order‑of‑magnitude gains.

Python developer Amirrea Azadmher cautions against over‑focusing on headline CI numbers. For him, the real value is in improving the edit–check loop during development. His advice to teams choosing a checker:

If you're evaluating Pyright vs Pyrefly vs mypy, don't trust someone else's monorepo numbers. Measure cold and warm times on your tree, and score diagnostics quality alongside throughput.

For teams building large backends, data pipelines, or tooling around Python—including embedded workflows—Google’s move is a strong signal that modern, Rust-based type checkers like Pyrefly are ready for serious production use.


Source: Google, InfoQ · Cover image: Google

Videolar

(1)