function-arguments by reference

JCM joshway_without_spam at myway.com
Tue Dec 30 11:08:34 EST 2003


EsC <christian.eslbauer at liwest.at> wrote:
> hy!

> thanks for your explanations!

> i want to avoid performance-problems by repeated (very often)
> function-calls with very long strings.
> in some languages (C, PHP, Powerbuilder, ...) i have the opportunity,
> to pass "by value" or "by reference/pointer)".

The text of the string is not copied; a reference to the string/object
is passed into the function.  You can modify objects passed into
functions (but only if they're mutable--strings and integers are
examples of immutable objects), but you cannot rebind the variable
holding the value in the caller's scope.

There have been some discussions in this newsgroup about whether
Python is call-by-value or not.  I'm not sure if I want to recommend
looking for them; there was no good consensus about the terminology.




More information about the Python-list mailing list