Josiah Carlson wrote:
> Talin <[EMAIL PROTECTED]> wrote:
>> The 'characters' data type would be particularly optimized for
>> character-at-a-time operations, i.e. building up a string one character
>> at a time. An example use would be processing escape sequences in
>> strings, where you are transforming the escaped string into its
>> non-escaped equivalent.
>
> That is already possible with array.array('H', ...) or array.array('L', ...),
> depending on the unicode width of your platform. Array performs a more
> conservative reallocation strategy (1/16 rather than 1/8), but it seems
> to work well enough. Combine array with wide character support in views,
> and we could very well have the functionality that you desire.
Well, one of the things I wanted to be able to do is:
'characters += str'
Or more precisely:
token_buf = characters()
token_buf += "example"
token_buf += "\n"
print token_buf
>>> "example\n"
Now, an ordinary list would concatenate the string *object* onto the end
of the list; whereas the character array would concatenate the string
characters to the end of the character array. Also note that the __str__
method of the character array returns a vanilla string object of its
contents.
(What I am describing here is exactly the behavior of Java StringBuffer.)
-- Talin
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe:
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com