lazy wrote: > Hi, > > I want to pass a string by reference. I understand that strings are > immutable, but Im not > going to change the string in the function, You're confused here. "Immutable" means it *cannot* be changed, so your decision to not change the string is not really your decision at all, but a consequence of the language. > just to aviod the overhead > of copying(when pass-by-value) because the > strings are long and this function will be called over and over > again. > I initially thought of breaking the strings into list and passing the > list instead, but I think there should be an efficient way. > > So is there a way to pass a const reference to a string? > > Thanks > > Strings *are* passed by reference *always*. There is no copy and no overhead. Efficiency is not based on length. Since the string is immutable, nothing you do inside the function can change the string outside the function.
Gary Herron -- http://mail.python.org/mailman/listinfo/python-list