Pointers and Objects in Python (Summary)
You now know how Python deals with objects and pointers! You learned about the differences between names and variables, which is important for understanding how Python handles variables. You also saw that you can simulate pointers in Python without sacrificing the memory safety that Python provides.
You can simulate pointers in Python by:
- Using mutable objects as low-overhead pointers
- Creating custom Python objects for ease of use
- Unlocking real pointers with the
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.
We covered a lot in this course. You learned how pointers work in C, the difference between mutable and immutable objects in Python, how you can utilize mutable objects and classes to mimic pointer behavior, and how Python code can interface with C using the
00:21 As you’ve learned, pointers don’t exactly exist in Python, but you can simulate the pass-by-reference behavior of pointers in Python, all without sacrificing the memory safety that Python provides. Using what you’ve learned in this course, you can write Python libraries that are easier to work with, and you can also encapsulate performance-critical parts of your Python code into C and pass pointers that way.
Become a Member to join the conversation.