lazy a écrit :
> 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, 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.

Once again : in Python, "variables" are just name=>ref pairs in a 
namespace. The concepts of "pass by ref" or pass by val" are meaningless 
here. Args passed to a function *are* references to objects - Python 
doesn't copy objects unless explicitelly asked to.

> I initially thought of breaking the strings into list and passing the
> list instead, but I think there should be an efficient way.

A typical case of premature "optimization" !-)

> So is there a way to pass a const reference to a string?

Yes : be lazy, and don't worry about that.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to