From the course: Programming Foundations: Memory, Pointers, and Garbage Collection
Unlock the full course today
Join today to access over 25,200 courses taught by industry experts.
Best practices with memory - Python Tutorial
From the course: Programming Foundations: Memory, Pointers, and Garbage Collection
Best practices with memory
- [Instructor] This point, you already know what pointers or references are. We have seen that when we share the reference, the object on the heap can be accessed from multiple places. This means that if we modify the object on the heap via one pointer, the object also was modified for other places in our code that are holding the same pointer, since there's only one object, and this very object has changed. So no news there. But this passing by reference is also true for returning objects from methods or for creating objects using other objects. The reference to the object gets sent. This way, the object can be accessed by the caller of the method. This can also happen through third-party libraries in our application. Whenever this happens without it being the intention, we call this escaping references. Even though this might not be too surprising to you, security breaches that this behavior can cause might be a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.