Simple String Question.

Cees de Groot cg at cdegroot.com
Wed May 15 19:44:32 UTC 2002


Bijan Parsia <bparsia at email.unc.edu> said:
>Important tip: concat is usually more expensive in Squeak than, say, in
>Python. Or rather, concat is not the preferred way to efficiently build
>large strings. E.g.,
>
IIRC, Python strings are immutable as well, so "a = b + c" will involve a
copy. I don't know whether Python optimizes for "b + c + d" (which Smalltalk
could do just as well), but I do know that Python has string streams just like
Smalltalk for just the same reasons (StringIO module).


>	'adfafds', 'adfdfa', 'adfa', 'adfasf'
>
[...]
>
>	WriteStream on: (String new: 1000).
>
And if you get bored with that, you might want to have some fun and implement
#, on WriteStream or maybe even on a special class (StringStream?) so you can
do something like 

  (StringStream , 'foo' , 'bar', 'baz') contents



-- 
Cees de Groot               http://www.cdegroot.com     <cg at cdegroot.com>
GnuPG 1024D/E0989E8B 0016 F679 F38D 5946 4ECD  1986 F303 937F E098 9E8B



More information about the Squeak-dev mailing list