To concatenate two strings, the memory manager will try to realloc one the memory location of one string so that the other will be able to fit the other string in memory next to it. https://stackoverflow.com/a/34008199/8366477Is the time-complexity of iterative string append actually O(n^2), or O(n)? If it cannot realloc in place, then it will have to move both into a new memory location.
Question is to avoid this overhead of moving two strings into a new memory location, is there a preferred, efficient way of concatenating two strings in Python. I'm thinking of using StringIO to make it into a text buffer? What are your thoughts?