O'Reilly logo

Learning Python Design Patterns by Gennadiy Zlobin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Facilitating Object Communication with Proxy and Observer Patterns

Sometimes you need to work with a large object—so large that it is better to defer its creation to the moment when it is actually used to save some memory and time. When it is created, it is better not to create it again on every new request, but use the previously created object and create a new reference. When all parts of the code have completed work with it, it is required that some memory be freed up as soon as possible. It means we need to count references to the heavy object, and to implement it, we need a middleman that does all this intermediate work. A proxy is the solution to this problem.

A Proxy is a design pattern that helps to decouple the client code from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required