It's troubling to read something about Python optimization/performance without mention that this is atrocious in a loop
string = string + s
That is such a code smell I cringed every time I saw it.
Should append to list and join at the end (once). Which, I bet (I, or you, don't know anything until we actually profile), dumping the += is significant reason why last two examples where much faster.
string = string + s
That is such a code smell I cringed every time I saw it.
Should append to list and join at the end (once). Which, I bet (I, or you, don't know anything until we actually profile), dumping the += is significant reason why last two examples where much faster.