decorator pattern uses this method to retrieve methods and attributes for an objectand by overriding this method we can add the decorator as we wanted since __getattribute__(returns methods and valueswe also need to check that the attribute requested is method class_profiler py import time def profiling_wrapper( )@wraps(fdef wrap_f(*args**kwargs)start_time time time(result (*args**kwargsend_time time time(elapsed_time end_time start_time print("[time elapsed for {}{}format(nelapsed_time)return result return wrap_f def profile_all_class_methods(cls)class profiledclass(object)def __init__(self*args**kwargs)self inst cls(*args**kwargsdef __getattribute__(selfs)tryx super(profiledclassself__getattribute__(sexcept attributeerrorpass elsex self inst __getattribute__(sif type( =type(self __init__)return profiling_wrapper(xelsereturn return profiledclass