Is there anything in Python like Java\'s StringBuffer
? Since strings are immutable in Python too, editing them in loops would be inefficient.
In the top answer, the link from "Efficient String Concatenation in Python" no longer links to the intended page (redirects to tensorflow.org instead). However, this page from 2004 with the exact code cited probably represents that page https://waymoot.org/home/python_string/ .
You may have seen it already since it comes up first if you google:
efficient python StringBuilder
I can't leave this in a comment, as I'm not privileged.