Rock Solid Python with Python Typing Transcripts
Chapter: Welcome to the Course
Lecture: Python Language Typing Definition

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's dive right into talking about Python type hints by starting with the language.
0:05 Here's the Wikipedia entry for Python itself. Let's look at a few things in this page here.
0:12 First of all, if we zoom in, you can see that Python is dynamically typed and garbage collected.
0:17 It supports multiple programming paradigms, including procedural, object-oriented and
0:22 functional, and is often described as a batteries included language because of its large standard
0:28 library. All this is true. The underlying part is what's relevant for us here in this course.
0:33 It is dynamically typed, dynamically typed languages generally don't have any type information
0:40 in the language whatsoever. It's just like, well, however you use it, that's how you use it. You
0:44 probably heard if it walks like a duck talks like a duck quacks like a duck, it is a duck.
0:48 Well, that's what they're saying right here. But if you looked at the first page, when we were
0:53 zoomed out there's a little sidebar on typing. Let's check that out. Typing discipline says you
0:59 can have duck typing, dynamic typing, strong typing, gradual typing, all of these interesting
1:05 things. So strong typing, that is what we're going to bring to Python with the ideas that
1:11 we're talking about in this course with type hints and other things that we can apply to our code,
1:16 either externally or directly in the code that we're writing. Also, you'll see this is gradual,
1:21 which is really awesome. That means when you want Python type hints, you can use them,
1:26 but you don't have to languages like C#, C++, Swift, Dart, they are not gradual, you have to
1:36 use typing, the strong typing from the beginning. Always if there's ever the smallest mismatch,
1:42 I said it was an integer here and I didn't specify it there. I said it was an integer here and it's a
1:46 a string there, whack, the program won't compile, it won't run. There's a million lines of code, one line is wrong, you're done.
1:54 Python is not at all like that. It's gradual. Moreover, the CPython runtime ignores type hints.
2:04 That probably needs to be in the little bracket seven up next to that where it tells you when
2:09 it ignores it and when it doesn't because there are times like for example, with fast
2:13 API where the runtime behavior is driven by the types. So the execution itself is not
2:21 entirely ignored, but at the CPython level, it is. So we're going to go and add stronger
2:29 typing gradually to CPython to other code that we write. And sometime it'll be ignored.
2:35 And that's an advantage. Other times, we won't allow it to be ignored. In that case, maybe its advantage as well.


Talk Python's Mastodon Michael Kennedy's Mastodon