反正r表示不理解
import time
def performance(f):
def fn(*args,**kw):
t1 = time.time()
r = f(*args,**kw)
t2 = time.time()
print 'call %s() in %fm' %(f.__name__,(t2-t1))
#return f(*args,**kw)
# return r(返回r和返回上面一行代码有上面区别吗 为上面要把 f(*args,**kw)赋值给r再返回r)????????????????
return fn
@performance
def factorial(n):
return reduce(lambda x,y: x*y, range(1, n+1))
print factorial(10)