Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 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...




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

Search: