string building
Chris Mellon
arkanes at gmail.com
Mon Apr 3 10:31:07 EDT 2006
On 4/3/06, John Salerno <johnjsal at nospamgmail.com> wrote:
> Out of curiosity, is there any kind of equivalent in Python to the
> StringBuilder class in C#? Here's a quick description from the .NET
> documentation:
>
> "This class represents a string-like object whose value is a mutable
> sequence of characters. The value is said to be mutable because it can
> be modified once it has been created by appending, removing, replacing,
> or inserting characters."
>
> It's used for dealing with large strings that otherwise would cause
> performance problems if used as regular string objects. I'm just
> wondering if Python has something like this, or if it is even really
> necessary. I know there is even some discussion on when exactly
> StringBuilder becomes useful over regular strings, but I imagine at some
> point it is good to use.
The StringIO module (and it's better performing counterpart,
cStringIO) present a string as a file-like object and are the
appropriate way to incrementally build large strings.
More information about the Python-list
mailing list