[Python-ideas] Mutable chars objects

Josiah Carlson jcarlson at uci.edu
Sun Mar 11 11:31:48 CET 2007

Talin <talin at acm.org> wrote:
> Something that I have wanted in Python for a long time is something like 
> the Java StringBuffer class - a mutable buffer, with string-like 
> methods, that holds characters instead of bytes.

8-bit ASCII characters, or compile-time specified unicode characters (16
or 32 bit)?  If all you wanted was mutable characters, array.array('c'),
it's smart about appending.  The lack of string methods kind of kills it

One of the reasons I was pushing for string views oh, about 7 months ago
was for very similar reasons; it would be *really* nice to be able to
add string methods to anything that provided the buffer interface. 
Nevermind that if it offered a multi-byte buffer view (like the extended
buffer interface that will be coming in Py3k), you could treat arbitrary
data as if it were strings - an array of 16 bit ints would be the same
as 8 bit ints, the same as 8 bit characters, the same as 32 bit ints,
etc.  I guess I was 7 months too early in my proposal.

 - Josiah

More information about the Python-ideas mailing list