Hacker News new | past | comments | ask | show | jobs | submit login

By the time you've written a Python that has all explicit types in it, and harvested the speed advantages the interpreter can have when it can count on that, and all the other cascading changes that would result, and the fact that you would discard 100% of all previous modules both Python and C, you might as well just start using one of the existing statically-typed languages that already has a mature ecosystem.

Python should be working on being the best Python it can be, not being an adequate Python and an inadequate bodged-on static language on the side.




> harvested the speed advantages the interpreter can have when it can count on that,

Does the interpreter actually optimize code based on type information? My knowledge is that it does not


Python 3 does not, but the hypothetical Python 4 would be crazy to put types on everything and then not accelerate its interpreter with the resulting data.

The problem Python 3 has is dynamic types, as the dynamically-typed languages implement them, are viral; one little crack lets them in somehow and all the code operating on the data has to assume it's viral.


I would be pleasantly surprised if they manage to do that. The current type checkers of Python, as useful as they are, hit the limit pretty fast, because of its extremely dynamic nature and the type system struggling to type check valid expressions. The number of times I've seen common pandas and numpy code not type check


CPython doesn't, but there is Mypyc [1] which compiles statically typed Python to faster C extensions leveraging the type information. As usual, this comes with tons of limitations [2]

[1]: https://mypyc.readthedocs.io/en/stable/

[2]: https://mypyc.readthedocs.io/en/stable/differences_from_pyth...


It's basically documentation to make it easier to use functions. After that people decided to enforce it basically as lints and only where possible. It feels like Python to me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: