Hacker News new | ask | show | jobs
by jrs95 3299 days ago
That's not entirely true. The information from the type annotations is available at runtime. ApiStar takes advantage of this, for example.
1 comments

The information from annotations is exposed to the runtime, but nothing in the runtime treats them as types or performs any type checking. The feature was introduced as a generic way to annotate functions, without being constrained to a single use case (type checking), and all the tools which actually do type-checking based on annotations are third-party.
C++ also does do any type checking at runtime. Compile time checking is all that really matters.
The CPython implementation does have a "compile" step (to produce bytecode, which is what actually gets executed, by a simple stack-based virtual machine), and does not do any type checking in that step no matter how many annotations you give it.