Pointers and Objects in Python (Overview)
If you’ve ever worked with lower-level languages like C orC++, then you may have heard ofpointers. Pointers are essentially variables that hold the memory address of another variable. They allow you to create great efficiency in parts of your code but can lead to various memory management bugs.
You’ll learn aboutPython’s object model and see why pointers in Python don’t really exist. For the cases where you need to mimic pointer behavior, you’ll learn ways to simulate pointers in Python without managing memory.
In this course, you’ll:
- Learn whypointers in Python don’t exist
- Explore the difference betweenC variables andPython names
- Simulate pointers in Python
- Experiment with real pointers using
ctypes
00:00Hi, I’m Austin Cepalia with realpython.com!And in this course, you’ll learn all about pointers and memory management in Python.Love them or hate them,pointers are essential to writing efficient code in many low-level languages.
00:16If you’ve ever worked with C or C++ then chances are,you are no stranger to the concept of pointers.If you haven’t, though, or you’re not familiar with pointers, that’s okay too.
00:28In the next two videos,I’ll explain all you need to know about pointers for the rest of this course.
00:35As we go along, we’ll also be looking at a little bit of code written in C.I’ll explain exactly what this code does as if you’ve never programmed in C before,so this course really doesn’t have any prerequisites.
00:50You’ll start by learning about why Pythondoesn’t actually support the idea of pointers,at least not in a traditional sense.To do that, you’ll look under the hood at variables and examine how Python managesdata types, references, and memory.
01:07Once you have a better understanding of pointers and memory management,I’ll show you some ways to simulate pointer behavior using just Python.
01:16Finally,you’ll learn how to create real C-style pointers with thectypes module,which will let you work with C libraries in your Python programs.
01:27Having pointers in your programmer’s toolkit will not only allow you to seea different way of working with program data,but it will also allow you to interface your Python code with C codethat requires the use of pointers.
01:42To start, I’ll explain the basics of pointers and why they’re often needed.
Course Contents

