Steven D'Aprano wrote:
On Mon, 20 Jul 2009 21:08:22 +1000, Ben Finney wrote:
What is it you're trying to do that makes you search for a mutable
string type? It's likely that a better approach can be found.
When dealing with very large strings, it is wasteful to have to duplicate
the entire string just to mutate a single character.
However, when dealing with very large strings, it's arguably better to
use the rope data structure instead.
The general problem is that whether strings are mutable or not is an
early language design decision, and few languages provide both.
Mutable strings need lots of data copying to be safe passing args to
unknown functions; immutable strings need lots of copying for ncremental
changes. The rope is a great idea for some cases.
I'd argue Python works better with immutable strings, because Python is
too slow at per-character operations to be running up and down strings
a character at a time, changing here and there. So it becomes more
natural to deal with strings as chunks to pass around, and it is nice
not to have to copy the strings when doing that passing around.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list