How Python Manages Memory (Summary)
Memory management is an integral part of working with computers. Python handles nearly all of it behind the scenes, for better or for worse. Python abstracts away a lot of the gritty details of working with computers. This gives you the power to work on a higher level to develop your code without the headache of worrying about how and where all those bytes are getting stored.
In this course, you learned:
- What memory management is and why it’s important
- How the default Python implementation, CPython, is written in the C programming language
- How the data structures and algorithms work together in CPython’s memory management to handle your data
If you’re interested in more low-level tuturials, check out these courses and articles:
- Pointers and Objects in Python
- Linked Lists in Python: An Introduction
- What is the Python Global Interpreter Lock (GIL)?
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00 Memory management is an integral part of dealing with computer programs. Luckily for us, Python manages all of this behind the scenes, so we can focus on our code and not how data is being stored in memory. In this course, you learned what memory management is and why it’s important, basic CPython functionality and why it was designed the way it was, and how the data structures and algorithms work together in CPython’s memory management to handle your data.
00:30 I hope this gives you a new appreciation for all that CPython does. It’s cool to think that there’s so much working under the hood so that we can rapidly develop our Python programs.
00:42 If you’re interested in more low-level tutorials like this, we’ve got a few great articles and courses here on realpython.com. This includes Pointers in Python, Linked Lists in Python, and an article about the GIL. These are all linked in the video notes down below.
thecocoa on Dec. 7, 2020
Thank you for this explanation.
Bo Stevens on Jan. 4, 2021
It was nice to learn about the garbage collector, and how Python is able to free up memory.
shangcode on Dec. 27, 2022
Got it, what a nice course.
Become a Member to join the conversation.
Varad Meru on Dec. 4, 2020
Thanks for this wonderful intro Austin. I had couple of questions - 1. Any place in GC and the workings are covered? 2. You mention that freepools and usedpools are stored as linked-lists. Where are the fullpools tracked?