def timed(function):
    """Decorator timing the method call and printing the result to `stdout`"""
    @wraps(function)
    def function_wrapper(obj, *args, **kwargs):
        """Wrapper function printing the time taken by the call to `function`"""
        name = obj.__class__.__name__ + '.' + function.__name__
        start = time.clock()
        result = function(obj, *args, **kwargs)
        print('{}: {:.4f} seconds'.format(name, time.clock() - start))
        return result
    return function_wrapper
def timed ( function ) : @ wraps ( function ) def function_wrapper ( obj , * args , ** kwargs ) : name = obj . __class__ . __name__ + '.' + function . __name__ start = time . clock ( ) result = function ( obj , * args , ** kwargs ) print ( '{}: {:.4f} seconds' . format ( name , time . clock ( ) - start ) ) return result return function_wrapper
Decorator timing the method call and printing the result to `stdout`