April 2019
Intermediate to advanced
646 pages
16h 48m
English
Proxy provides indirect access to an expensive or distant resource. Proxy sits between a Client and a Subject, as shown in the following diagram:

It is intended to optimize Subject accesses if they are expensive. For instance, the memoize() and lru_cache() decorators described in Chapter 12, Test-Driven Development, can be considered proxies.
A proxy can also be used to provide smart access to a subject. For instance, big video files can be wrapped into proxies to avoid loading them into memory when the user just asks for their titles.
An example is given by the urllib.request module. urlopen is a proxy for the content located at a remote ...