3 ms·
Appending to a immutable string in a loop is O(n^2). I'm surprised the author is surprised by this. Python and Java is the same. Sure, it's possible for the vm
by gorset 15y ago
Appending to a immutable string in a loop is O(n^2). I'm surprised the author is surprised by this. Python and Java is the same.
Sure, it's possible for the vm to optimize this by either using ropes or convert to a buffer based on some kind of code analysis, but you shouldn't bet on it.