11 comments

[ 466 ms ] story [ 2824 ms ] thread
Python type hints are a step backwards in the evolution of programming languages. There, I said it.

Before the pitchforks come out, I love types and I love dynamic languages too.

But if I have to create a struct[struct[struct] for a type, and then import it with an obnoxious "if TYPE_CHECKING:" and then have to use an IDE that can do static analysis to even make sense of types, I might as well use a well-designed JVM language.

This. I tried to love gradually typed languages. But they just seem as the worst of both worlds to me.
I kind of agree, but I feel like the retrofitting of gradual types onto existing languages is often awkward even though the idea of gradual typing itself is very good.
I dont't know, I have the opposite experience. In Python you can have a function that returns a certain object `Publication` most of the time. But sometimes it returns a slightly different object `MyPublication`. This doesn't have to be due to bad design, maybe it comes from some library function and you didn't even notice. Due to duck typing it will work (until you do something with the result that only one version supports). Then sometimes you will return None, and sometimes "[something]".

Type annotations are really valuable to ensure that your types are actually what you think they are. In the same spirit of using assertations for pre and post conditions.

What you are enjoying is called a good type system, not Python's type annotation specifically. The comparison is with other typed/type-hinted languages, not with Python 2.7.
900ns is not a millisecond?
Right, seems like the author is basing the article of a unit confusion of 3 orders of magnitude..
Benchmarking is hard to do well. Benchmarking on modern machines is very hard (dynamic clocks, caching, more). Benchmarking on code that runs in less than a milisecond is very very hard. If you care about this performance you probably should not use Python. I'll take better checked, more readable Python over faster Python any day.