On Wed, Feb 13, 2013 at 5:42 PM, Alexandre Vassalotti firstname.lastname@example.org wrote:
On Tue, Feb 12, 2013 at 5:25 PM, Christian Tismer email@example.com wrote:
Would ropes be an answer (and a simple way to cope with string mutation patterns) as an alternative implementation, and therefore still justify the usage of that pattern?
I don't think so. Ropes are really useful when you work with gigabytes of data, but unfortunately they don't make good general-purpose strings. Monolithic arrays are much more efficient and simple for the typical use-cases we have in Python.
If I recall correctly, io.StringIO and io.BytesIO have been updated to use ropes internally in 3.3. Writing to one of those and then calling getvalue() at the end is the main alternative to the list+join trick (when concatenating many small strings, the memory saving relative to a list can be notable since strings have a fairly large per-instance overhead).