请问在下面这段代码里面return r和return f有什么不一样,为什么return f就是错的
import time
def performance(text):
def log_decorator(f):
def fn(*args,**kw):
t1 = time.time()
r = f(*args,**kw)
t2 = time.time()
t = (t2-t1)*1000 if text=='ms' else (t2-t1)
print 'call %s() in %fs' %(f.__name__,t)
return r
return fn
return log_decorator
@performance('ms')
def factorial(n):
return reduce(lambda x,y:x*y,range(1,n+1))
print factorial(10)