7 ms·
It's not so much large strings as lots of concatenation; aggregating all the substrings into a list and joining saves allocations and at least at one point in t
by dragonwriter 7y ago
It's not so much large strings as lots of concatenation; aggregating all the substrings into a list and joining saves allocations and at least at one point in time it gave a huge speedup on a number of large systems. While Python's overall performance has improved since then, my understanding is that creating lots of strings and incrementally assembling the allocating and dropping lots of progressively-larger items is still often a significant performance hit.