[ tracename bob tracepay tracename sue tracepay tracename bob tracepay [ notice how there is one wrapper class with state retention per decorationgenerated by the nested class statement in the tracer functionand how each instance gets its own fetches counter by virtue of generating new wrapper instance as we'll see aheadorchestrating this is trickier than you may expect applying class decorators to built-in types also notice that the preceding decorates user-defined class just like in the original example in we can also use the decorator to wrap up built-in type such as listas long as we either subclass to allow decoration syntax or perform the decoration manually--decorator syntax requires class statement for the line in the followingx is really wrapper again due to the indirection of decorationfrom interfacetracer import tracer @tracer class mylist(list)pass mylist tracer(mylistx mylist([ ] append( traceappend wrapped [ triggers wrapper(triggers __getattr__append wraplist tracer(listx wraplist([ ] append( traceappend wrapped [ or perform decoration manually else subclass statement required the decorator approach allows us to move instance creation into the decorator itselfinstead of requiring premade object to be passed in although this seems like minor differenceit lets us retain normal instance creation syntax and realize all the benefits of decorators in general rather than requiring all instance creation calls to route objects decorators