Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import timeit
- num = 10000
- t1 = timeit.Timer('testfunc(1)', 'def testfunc(x): return 5+x;')
- t2 = timeit.Timer('testlambda(1)', 'testlambda = lambda x: x+5;')
- time1 = t1.timeit(number=num)
- time2 = t2.timeit(number=num)
- print 'simple function:',time1/num
- print 'simple lambda:',time2/num
- '''
- squishy@EXCALIBUR ~/Documents $ python funcvlambda.py
- simple function: 2.92284110007e-07
- simple lambda: 2.90683115584e-07
- '''
Add Comment
Please, Sign In to add comment