return [ for in range( ) listcomp( =listcomp listcomp( =listcomp listcomp( =listcomp listcomp alltime as isthis timing function decorator can be used for any functionboth in modules and interactively in other wordsit automatically qualifies as general-purpose tool for timing code in our scripts watch for another example of decorator arguments in the section "implementing private attributeson page and again in " basic rangetesting decorator for positional argumentssupporting methodsthis section' timer decorator works on any functionbut minor rewrite is required to be able to apply it to class-level methods too in shortas our earlier section "class blunders idecorating methodson page illustratedit must avoid using nested class because this mutation was deliberately reserved to be subject of one of our end-of-quiz questionsthoughi'll avoid giving away the answer completely here coding class decorators so far we've been coding function decorators to manage function callsbut as we've seendecorators have been extended to work on classes too as of python and as described earlierwhile similar in concept to function decoratorsclass decorators are applied to classes instead--they may be used either to manage classes themselvesor to intercept instance creation calls in order to manage instances also like function decoratorsclass decorators are really just optional syntactic sugarthough many believe that they make programmer' intent more obvious and minimize erroneous or missed calls singleton classes because class decorators may intercept instance creation callsthey can be used to either manage all the instances of classor augment the interfaces of those instances to demonstratehere' first class decorator example that does the former--managing all instances of class this code implements the classic singleton coding patternwhere at most one instance of class ever exists its singleton function defines and returns function for managing instancesand the syntax automatically wraps up subject class in this functioncoding class decorators