string copying

Jeff Shannon jeff at ccvcorp.com
Fri Mar 29 17:41:22 EST 2002


In article <AZ3xhtAObNp8EwwK at jessikat.fsnet.co.uk>, 
robin at jessikat.fsnet.co.uk says...
> Is there some special reason why python inhibits string copying. I
> suppose there's some attempt being made to make these constants. To make
> differing versions of 'abc' one has to resort to silliness like 'ab'+'c'

1) Strings are immutable.  This implies that there is zero 
practical difference between two references to two separate 
string objects of identical value, and two references to the same 
string object.

2) Keeping point #1 in mind, it is both faster and more memory-
efficient to use the same string object wherever practical.

3) Why on earth are you even worried about object identity for 
simple strings???  ;)

-- 

Jeff Shannon
Technician/Programmer
Credit International



More information about the Python-list mailing list