...

/

'+=' Is Faster

'+=' Is Faster

We'll cover the following...

Time is of the essence of and we need fast code executions.

Press + to interact
import timeit
# using "+", three strings:
print(timeit.timeit("s1 = s1 + s2 + s3", setup="s1 = ' ' * 100000; s2 = ' ' * 100000; s3 = ' ' * 100000", number=100))
# using "+=", three strings:
print(timeit.timeit("s1 += s2 + s3", setup="s1 = ' ' * 100000; s2 = ' ' * 100000; s3 = ' ' * 100000", number=100))

...

...