Re:Pyrefly vs. Ty: Comparing Python's Two New Rust-Based Typ...
by eternityforest on Tuesday May 27, 2025 @01:47PM
(#44109135)
Pydantic also takes CPU time and doesn't do anything till runtime.
Type checking is real time in the IDE and lets you fix stuff before you waste fifteen minutes actually running it.
Re:Pyrefly vs. Ty: Comparing Python's Two New Rust-Based Typ...
by Spivak on Tuesday May 27, 2025 @01:47PM
(#44109137)
pydantic does have @validate_call for this use-case.
Re:Pyrefly vs. Ty: Comparing Python's Two New Rust-Based Typ...
by guappa on Wednesday May 28, 2025 @04:33AM
(#44113890)
Profile it and see how much slower it gets :)
Re:Pyrefly vs. Ty: Comparing Python's Two New Rust-Based Typ...
by belmont_sup on Tuesday May 27, 2025 @11:01PM
(#44112406)
To be clear, I myself prefer sound type systems.
But the reality is that teams have started with untyped Python, Ruby, and Javascript, have been productive, and now need to gradually add static types to remain productive.
> Every caller would need to check that the function...
The nice part here is where the gradual part comes in. As you are able to type more of your code, you're able to move where you add your runtime validation, and eventually you'll be able to move all validation to the edges of your system.
That's the problem with bugs though, there's always something that could have been done to avoid it =)
Pydantic works great in specific places, like validating user supplied data, but runtime checks as a replacement for static type checkers are not really feasible.
Every caller would need to check that the function is being called correctly (number and position of args, kwarg names, etc) and every callee would need to manually validate that each arg passed matches some expected type.