[Python-ideas] Create a StringBuilder class and use it everywhere

k_bx k.bx at ya.ru
Thu Aug 25 17:28:34 CEST 2011

> This doesn't seem nicer to read and write to me than the list form. I
> also do not see any reason to believe it will stop people from doing
> it the quadratic way if the ubiquitous make-a-list-then-join idiom
> does not.

The whole point is that people don't write u''.join idiom just because they don't know it is slow.
And when they see StringBuilder -- they can ask themselves "why is he using that".

I don't mind using u''.join, but it just doesn't make people think about speed at all.

The most popular (as from what I can see) thing right now where people start seeing
that += is slow is when they try to do that on PyPy (which doesn't have hack like CPython,
who is still slow) and ask "why my pypy code is sooooo slow".

With StringBuilder used widely that would not be the case.

More information about the Python-ideas mailing list