Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # join_vs_concat_surprise.py
- from time import clock
- def timer(test):
- ttt = clock()
- exec(test)
- print test
- print "{:.8f}".format(clock()-ttt)
- print
- limit = 10**6
- def concat_str():
- resp = ''
- for num in xrange(limit):
- resp += `num`
- return resp
- timer('''concat_str()''')
- def join_list():
- return ''.join([`num` for num in xrange(limit)])
- timer('''join_list()''')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement