Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- text = "Hello"
- before = time.time()
- for _ in range(100000000):
- text += '0'
- print(f'slow method: {time.time()-before:.02f}')
- text = ["Hello"]
- before = time.time()
- for _ in range(100000000):
- text.append('0')
- final = ''.join(text)
- print(f'slow method: {time.time()-before:.02f}')
- # slow method: 645.54
- # slow method: 19.04
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement