On Mar 11, 2006, at 7:43 PM, Mc Osten wrote:

> Logan Capaldo ha scritto:
>
>> For  the most part if it makes sense that something should be  
>> mutable, it is. I don't think that mutability is ever determined  
>> on the basis of performance ( except for maybe symbols)
>
> Having some object immutable allows some optimization otherwise not  
> possible. On the other hand makes some algorithms *slow*.
>
> The typical case is concatenating a lot of strings. In python it is  
> terribly unefficient, it's better to use StringIO objects (kind of  
> file in memory) or joining arrays.
>
> However, I think the real reason is:
> in Python dictionary (hash) keys are supposed to be immutable  
> (again, for performance reasons, I've been told). Since hashes that  
> could not use strings as keys would be quite useless, strings are  
> immutable.
>
> ObjectiveC has both mutable and unmutable. But since in Python  
> "there should be only one way to do it", strings are just unmutable.
>
> But not to go too off-topic...
>
> I noticed that strings are mutable in ruby since << adds to  
> existing string. But I found out sometimes += creates a new string  
> objetc...
>
>
>

I'm sorry I made that sound more general than I meant. I meant _in  
ruby_ generally immutablity/mutability was not decided on the basis  
of performance concerns