News for hackers. Stuff that matters.
Re:Ty: A fast Python type checker and language server by simonw on Wednesday May 07, 2025 @02:39PM (#43919200)
Here's what I got against one of my larger open source projects:

  cd /tmp
  git clone https://github.com/simonw/sqlite-utils
  cd sqlite-utils
  uvx ty check
Here's the output: https://gist.github.com/simonw/a13e1720b03e23783ae668eca7f6f...

Adding "time uvx ty check" shows it took:

  uvx ty check  0.18s user 0.07s system 228% cpu 0.109 total
Re:Ty: A fast Python type checker and language server by alexmolas on Wednesday May 07, 2025 @02:46PM (#43919271)
how does it compare against mypy? is it much faster?
Re:Ty: A fast Python type checker and language server by IshKebab on Wednesday May 07, 2025 @04:05PM (#43920064)
How does it compare against Pyright. Pyright is the gold standard of Python type checking currently. Mypy is slower and buggier.
Re:Ty: A fast Python type checker and language server by Redoubts on Wednesday May 07, 2025 @04:09PM (#43920099)
Mypy is also able to check things that are inexpressible with stubs, among other things
Re:Ty: A fast Python type checker and language server by scosman on Wednesday May 07, 2025 @05:29PM (#43920746)
0.2s on ty compared to 4.7s on pyright. Not even close.
Re:Ty: A fast Python type checker and language server by mil22 on Wednesday May 07, 2025 @07:56PM (#43921676)
I tested it side-by-side on my ~100Kloc codebase.

Ty: 2.5 seconds, 1599 diagnostics, almost all of which are false positives

Pyright: 13.6 seconds, 10 errors, all of which are actually real errors

There's plenty of potential here, but Ty's type inference is just not as sophisticated as Pyright's at this time. That's not surprising given it hasn't even been released yet.

Whether Ty will still perform so much faster once all of Pyright's type inference abilities have been matched or implemented - well, that remains to be seen.

Pyright runs on Node, so I would expect it to be a little slower than Ty, but perhaps not by very much, since modern JS engines are already quite fast and perform within a factor of ~2-3x of Rust. That said, I'm rooting for Ty here, since even a 2-3x performance boost would be useful.

Re:Ty: A fast Python type checker and language server by simonw on Wednesday May 07, 2025 @04:46PM (#43920391)
In the same folder:

    time uvx mypy .    
Result:

    uvx mypy .  0.46s user 0.09s system 74% cpu 0.740 total
So ty is about 7x faster - but remember ty is still in development and may not catch the same errors / report false errors, so it's not a fair comparison yet.
Re:Ty: A fast Python type checker and language server by hauntsaninja on Wednesday May 07, 2025 @05:45PM (#43920870)
Note that `uvx mypy` may give you inaccurate timings on macOS. The antivirus in macOS goes a little crazy the first time it executes a mypyc compiled program.
Re:Ty: A fast Python type checker and language server by diggan on Thursday May 08, 2025 @06:49AM (#43924943)
I'm not sure if it's using your environment correctly, or are you expecting ~150 errors? Lots of import errors, and I'm guessing most of the other ones are errors because it couldn't infer what was imported.