On May 9, 2016 5:31 AM, "Tim Chase" <python.l...@tim.thechases.com> wrote: > > then that's a bad code-smell (you get quadratic behavior as the > strings are constantly resized), usually better replaced with >
I just want to point out that in Python s += str in loop is not giving quadratic behavior. I don't know why but it runs fast. I'm very much interested to know why it is so? In [3]: %%timeit ...: s = '' ...: for x in xrange(10**6): ...: s += str(x) ...: 1 loop, best of 3: 383 ms per loop In [4]: %%timeit s = '' for x in xrange(10**6): s = s + str(x) ...: 1 loop, best of 3: 383 ms per loop -- https://mail.python.org/mailman/listinfo/python-list