I'm just curious why all examples of proxy-pattern written in Python are using composition over inheritance? If proxy class should implement all of the methods of original class, isn't it easier to inherit proxy from original and just overwrite methods we want to perform additional logic (caching, logging, etc.), using super().method()
?
The relationship between classes is also respected: the proxy class is some kind of an original class.
Example:
class Original:
def some_method(self):
return "some"
def another_method(self):
return "another"
class Proxy(Original):
def another_method(self):
res = super().another_method()
logger.log(res)
return res