我如果想同时求两个数的阶乘,应该如何修改代码呢?
import time
def performance(unit):
def decorate (f):
def warpper(*args, **kw):
timestart = time.time()
r = f(*args, **kw)
timeend = time.time()
if unit == 'ms':
t=(timeend - timestart)*1000
else:
t = timeend - timestart
print 'call %s() in %f %s' % (f.__name__, t, unit)
return r
return warpper
return decorate
@performance('ms')
def factorial(n,m):
return reduce(lambda x,y: x*y, for x in range(1, n+1), for y in range(1, m-1))
print factorial(10,9)