Discuss / Python / 第一题

第一题

Topic source

Carlos_EN

#1 Created at ... [Delete] [Delete and Lock User]

-- coding: utf-8 --

import time,functools

def metric(fn): @functools.wraps(fn) def wrapper(a,**b): now=time.time() n=fn(a,**b) now=time.time()-now print('%s executed in %s ms'%(fn.name,now)) return n return wrapper @metric

def fast(x,y): print('x+y=%d' % (x+y)) fast(2,4)


  • 1

Reply