Guido van Rossum
๐ค SpeakerAppearances Over Time
Podcast Appearances
And here is a function that returns a list of strings.
But that's not checked when you run the code.
But exactly.
There is a separate piece of software called a static type checker that reads all your source code without executing it and thinks long and hard about...
what it looks from just reading the code that code might be doing.
and double checks if that makes sense if you take the types as annotated into account.
So this is something you're supposed to run as you develop?
It's like a linter, yeah.
That's definitely a development tool, but the type annotations currently are not used for speeding up the interpreter.
And there are a number of reasons.
Many people don't use them.
Even when they do use them, they sometimes contain lies, where the static type checker says everything's fine.
I cannot prove that this integer is ever not an integer, but at runtime, somehow someone manages to violate that assumption.
And the interpreter...
ends up doing just fine.
If we started enforcing type annotations in Python, many Python programs would no longer work.
And some Python programs wouldn't even be possible because they're too dynamic.
And so we made a choice of not using the annotations.
There is a possible future where eventually
three, four, five releases in the future, we could start using those annotations to sort of provide hints because we can still say, well, the source code leads us to believe that these X and Y are both integers.