[ create a new paste ] login | about

Link: http://codepad.org/yGvFN65x    [ raw code | output | fork ]

python@2ch - Python, pasted on Jun 28:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from timeit import Timer

VALUE = 1

def bool_test():
  return bool(VALUE)

def not_not_test():
  return not not VALUE

def and_or_test():
  return VALUE and True or False

if __name__ == '__main__':
  print Timer('bool_test()', 'from __main__ import bool_test').timeit()
  print Timer('not_not_test()', 'from __main__ import not_not_test').timeit()
  print Timer('and_or_test()', 'from __main__ import and_or_test').timeit()


Output:
1
2
3
1.42439889908
0.835031986237
0.9924929142


Create a new paste based on this one


Comments: