Pyrefly and Ty are new Python type checkers implemented in Rust, aiming for improved performance compared to mypy. Pyrefly prioritizes speed and compatibility with existing mypy codebases, leveraging Rust's performance advantages without requiring significant changes for users already using mypy. Ty, while also faster than mypy, focuses more on a stricter type system with additional features and tighter integration with Rust, potentially requiring more code adaptations. Both projects are still in early stages but represent promising advancements for Python type checking, offering potentially faster and more powerful alternatives to existing tools.
Meta has introduced PyreFly, a new Python type checker and IDE integration designed to improve developer experience. Built on top of the existing Pyre type checker, PyreFly offers significantly faster performance and enhanced IDE features like richer autocompletion, improved code navigation, and more informative error messages. It achieves this speed boost by implementing a new server architecture that analyzes code changes incrementally, reducing redundant computations. The result is a more responsive and efficient development workflow for large Python codebases, particularly within Meta's own infrastructure.
Hacker News commenters generally expressed skepticism about PyreFly's value proposition. Several pointed out that existing type checkers like MyPy already address many of the issues PyreFly aims to solve, questioning the need for a new tool, especially given Facebook's history of abandoning projects. Some expressed concern about vendor lock-in and the potential for Facebook to prioritize its own needs over the broader Python community. Others were interested in the specific performance improvements mentioned, but remained cautious due to the lack of clear benchmarks and comparisons to existing tools. The overall sentiment leaned towards a "wait-and-see" approach, with many wanting more evidence of PyreFly's long-term viability and superiority before considering adoption.
Pyrefly is a new Python type checker built in Rust that prioritizes speed. Leveraging Rust's performance, it aims to be significantly faster than existing Python type checkers like MyPy, potentially by orders of magnitude. Pyrefly achieves this through a novel incremental checking architecture designed to minimize redundant work and maximize caching efficiency. It's compatible with Python 3.7+ and boasts features like gradual typing and support for popular type hinting libraries. While still under active development, Pyrefly shows promise as a high-performance alternative for type checking large Python codebases.
Hacker News users generally expressed excitement about Pyrefly, praising its speed and Rust implementation. Some questioned the practical benefits given existing type checkers like MyPy, with discussion revolving around performance comparisons and integration into developer workflows. Several commenters showed interest in the specific technical choices, asking about memory usage, incremental checking, and compatibility with MyPy stubs. The creator of Pyrefly also participated, responding to questions and clarifying design decisions. Overall, the comments reflected a cautious optimism about the project, acknowledging its potential while seeking more information on its real-world usability.
Summary of Comments ( 98 )
https://news.ycombinator.com/item?id=44107655
Hacker News users discussed the relative merits of Pyrefly and Ty, two new Rust-based Python type checkers. Some found Pyrefly's approach of compiling to Rust more interesting than Ty's runtime checks, appreciating the potential performance benefits and the ability to catch errors earlier. Others expressed skepticism about the practical benefits of either, citing existing tools like MyPy and the general overhead of type checking. A few questioned the need for Rust in these projects specifically, suggesting that the performance gains might be negligible for Python codebases and the added complexity could be a barrier to adoption. Several commenters noted the difficulty of type checking dynamic features of Python, while others pointed out the lack of significant detail in the comparison, making a definitive judgment difficult. Overall, the discussion highlighted the ongoing exploration of improved type checking for Python and the various tradeoffs involved in different approaches.
The Hacker News thread for "Pyrefly vs. Ty: Comparing Python's two new Rust-based type checkers" contains several comments discussing the relative merits and drawbacks of each project.
One commenter points out that the performance comparison in the original blog post isn't entirely fair because Pyright is being run in "watch" mode, which incurs overhead for monitoring file changes. They suggest a fairer comparison would involve running both tools in a single-shot mode.
Another commenter highlights the different design philosophies behind the two projects. Ty aims to be more conservative and focuses on compatibility with the existing Python ecosystem, while Pyrefly prioritizes performance and aims to eventually support more advanced type checking features. This difference in approach leads to trade-offs in terms of strictness and supported features.
There's discussion about the practicality of type checkers for large, real-world Python codebases. One commenter expresses skepticism about the usefulness of strict type checking in dynamically typed languages like Python, arguing it can add significant overhead without proportional benefits, especially in larger projects where maintaining type annotations can become cumbersome.
Another user questions the long-term viability of projects like Pyrefly and Ty, suggesting that mypy, with its established community and wider adoption, will likely remain the dominant type checker for Python. They also raise the concern that relying on Rust for core type checking functionality might introduce complexity and limit contributions from developers unfamiliar with Rust.
Some commenters express interest in exploring the internals of Pyrefly and its use of Rust, seeing it as a potential model for other performance-sensitive Python tooling. They praise the project's architecture and its focus on leveraging Rust's performance benefits.
The discussion also touches upon the challenges of parsing Python code, especially given its dynamic nature and the complexities of the Abstract Syntax Tree (AST). Commenters acknowledge the difficulty of this task and commend the efforts of both Pyrefly and Ty in tackling it.
Finally, there's a brief exchange about the overall trend of leveraging Rust for performance-critical components in Python projects, with commenters expressing optimism about this approach and its potential to improve the performance of various Python tools.