[Tutor] capitalize() but only first letter

Erik Price erikprice@mac.com
Thu Feb 6 08:07:01 2003


On Wednesday, February 5, 2003, at 10:49  PM, Sean 'Shaleh' Perry wrote:

>> Let me just play devil's advocate here then, because I'm a little
>> confused -- if it avoids creating multiple intermediate strings, then
>> what would those elements of the tuple be?  They are not references to
>> string objects?  (I sound obstinate here but I'm trying to be 
>> curious.)
>>
>
> yes it generates a throw away tuple.  Not quite as bad as a list, but 
> it does
> create that object.

A tuple with string-based elements, right?  So what I'm confused about 
is how the strings in the tuple are more memory-efficient than just 
using strings with the concat operator.

Unless it is because every time a concatenation is performed, then a 
*new* string is created, so you end up with (x + (x - 1)x) strings 
(because as the parser moves to the next string, it creates a new 
string to represent the strings concatted thus far, then again with the 
*next* string, etc).

Whereas with the tuple or list, you just have a set of x strings and 
they are all merged in one fell swoop at the same time, with no 
"intermediate" strings.

I think I understand it now.  Thanks!


Erik





-- 
Erik Price

email: erikprice@mac.com
jabber: erikprice@jabber.org