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.
Ty is a fast, incremental type checker for Python aimed at improving the development experience. It leverages a daemon architecture for quick startup and response times, making it suitable for use as a language server. Ty prioritizes performance and minimal configuration, offering features like autocompletion, error checking, and jump-to-definition within editors. Built using Rust, it interacts with Python via the pyo3 crate, providing a performant bridge between the two languages. Designed with an emphasis on practicality, Ty aims to be an easy-to-use tool that enhances Python development workflows without imposing significant overhead.
Hacker News users generally expressed interest in ty
, praising its speed and ease of use compared to other Python type checkers like mypy
. Several commenters appreciated the focus on performance, particularly for large codebases. Some highlighted the potential benefits of the language server features for IDE integration. A few users discussed specific features, such as the incremental checking and the handling of type errors, comparing them favorably to existing tools. There were also requests for specific features, like support for older Python versions or integration with certain editors. Overall, the comments reflected a positive reception to ty
and its potential to improve the Python development experience.
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.