Python Memory Management and Tips Transcripts
Chapter: Python variables and memory
Lecture: Python roughly equals CPython
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
it's time to get into Python memory management properly and start writing some code and looking at how things work behind the scenes.
0:08
We're going to start by focusing on variables. Now, you might think the place to start would be garbage collection or creating new
0:16
memory or whatever, but to understand how all those things work,
0:18
we're gonna start by talking about variables and how Python manages them, passes them around and
0:24
so on. We're gonna start in a place that might surprise you for a Python course. We're gonna talk about
0:29
C. Now, just to be clear, it's only a little bit of C. If you don't know the C programming language,
0:34
don't worry, it's a few lines of code, I'll talk you through it. The reason we're gonna talk about C is when you talk about Python,
0:42
people say "Oh, you just type Python and you run that". What they almost always mean is CPython,
0:48
right? Python is actually the programming language implemented in C. And you can go, we'll talk about some places where you can see the source
0:56
code, how things work in the actual implementation of the Python runtime. Some people call the thing that executes Python,
1:04
a "Python interpreter". That's true for CPython. There are many other things that run Python that do so that is not interpreted. We've got PyPy,
1:14
which is a JIT compiler, not an interpreter, you've got Cython and so on, so I prefer runtime. But if you want to say interpreter,
1:21
same basic thing here. So what we're gonna do is we're going to talk a
1:26
little bit about C and how specifically pointers and things like that in C surface when we actually get to the Python language,
1:34
because even though there's other ways to run Python, the vast majority of people do so on CPython.