Python Memory Management and Tips Transcripts
Chapter: Python variables and memory
Lecture: Python roughly equals CPython
0:00 it's time to get into python memory management properly and start writing some code and looking
0:05 at how things work behind the scenes.
0:07 We're going to start by focusing on variables.
0:11 Now, you might think the place to start would be garbage collection or creating new
0:15 memory or whatever, but to understand how all those things work,
0:17 we're gonna start by talking about variables and how Python manages them, passes them around and
0:23 so on. We're gonna start in a place that might surprise you for a Python
0:27 course. We're gonna talk about
0:28 C. Now, just to be clear, it's only a little bit of C.
0:32 If you don't know the C programming language,
0:33 don't worry, it's a few lines of code, I'll talk you through it.
0:37 The reason we're gonna talk about C is when you talk about Python,
0:41 people say "Oh, you just type Python and you run that".
0:44 What they almost always mean is CPython,
0:47 right? Python is actually the programming language implemented in C.
0:52 And you can go, we'll talk about some places where you can see the source
0:55 code, how things work in the actual implementation of the Python runtime.
1:00 Some people call the thing that executes Python,
1:03 a "Python interpreter". That's true for CPython.
1:06 There are many other things that run Python that do so that is not interpreted.
1:11 We've got PyPy,
1:13 which is a JIT compiler, not an interpreter, you've got Cython and so on,
1:17 so I prefer runtime. But if you want to say interpreter,
1:20 same basic thing here. So what we're gonna do is we're going to talk a
1:25 little bit about C and how specifically pointers and things like that in C surface when
1:32 we actually get to the Python language,
1:33 because even though there's other ways to run python,
1:36 the vast majority of people do so on Cpython.