Precompute the length of the final string, generate it, then go and replace the chunks as needed. a "".join() is still somehow better, but if you keep increasing a string at each step, you will do a lot of reallocation every few steps.
Glad you appreciate; doing concatenation is not necessarily the most performing way to achieve what you need to achieve, but it can work pretty fine :)
Precompute the length of the final string, generate it, then go and replace the chunks as needed. a
"".join()
is still somehow better, but if you keep increasing a string at each step, you will do a lot of reallocation every few steps.Glad you appreciate; doing concatenation is not necessarily the most performing way to achieve what you need to achieve, but it can work pretty fine :)