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

Antoine Pitrou solipsis at pitrou.net
Mon Aug 29 18:10:11 CEST 2011


Le lundi 29 août 2011 à 19:04 +0300, k.bx at ya.ru a écrit :
> 
> Ok, so I think the best approach would be to implement via join + [],
> but do flush every 1000 ops, since it can save memory.

That approach (or a similar one) could actually be integrated into
StringIO and BytesIO. As long as you only write() at the end of the
in-memory object, there's no need to actually concatenate.

And it would be much easier (and less impacting on C extension code) to
implement that approach in the StringIO and BytesIO objects, than in the
bytes and str types as Larry did.

Regards

Antoine.





More information about the Python-ideas mailing list