Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import time
- def reg():
- s = raw_input('input:')
- l = 0
- t = time.time()
- r = re.compile(r"^\d+$")
- for i in range(10000):
- if r.match( s):
- l -= 1
- else:
- l += 1
- print 'reg:'
- print time.time() - t
- def try_func():
- s = raw_input('input:')
- l = 0
- t = time.time()
- for i in range(10000):
- try:
- d = int(s)
- l -= 1
- except:
- l += 1
- print 'try_func:'
- print time.time() - t
- if __name__ == '__main__':
- reg()
- try_func()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement