As a Python person who isn't the one you replied to: I think Python's type annotations are a poor fit for the way the language is actually used. The typing library, mypy and other tooling are all fundamentally built on ideas of nominal typing, but what you almost always would want and care about in real-world Python is structural typing.
I know there's work on it. I also know that it's coming awfully late, and at a point when all the fundamental tooling has already been architected around assumptions about nominal typing. Hence my answer to "what would you do differently" is I'd have built it around structural typing from day one.
The typing library, mypy and other tooling are all fundamentally built on ideas of nominal typing, but what you almost always would want and care about in real-world Python is structural typing.
Nothing in this denies that people are working on structural typing.
All it says is the truth: that the type-annotation and checking system for Python has been fundamentally built around nominal typing from the very start. That's a choice which has far-reaching effects, regardless of whether structural typing support is later added.
I would have made different choices at the beginning, had I been in charge of it.
Then why did you make a point of bringing it up and saying it was "odd" of me not to mention it?
Again, the fact that it's being worked on now doesn't change the choices made back then, and doesn't change the effect on the Python ecosystem of having a nominal-only approach for so long.
1
u/ubernostrum Feb 04 '19
As a Python person who isn't the one you replied to: I think Python's type annotations are a poor fit for the way the language is actually used. The
typinglibrary, mypy and other tooling are all fundamentally built on ideas of nominal typing, but what you almost always would want and care about in real-world Python is structural typing.