I\'ve recently been using python more and more in place of c/c++ because of it cuts my coding time by a factor of a few. At the same time, when I\'m processing large amounts of
So i'm going to have to quote EOL on this because I think his answer is very relevant:
3) The last point is related to the question title: "passing by value" and "passing by reference" are not concepts that are relevant in Python. The relevant concepts are instead "mutable object" and "immutable object". Lists are mutable, while numbers are not, which explains what you observe. Also, your Person1 and bar1 objects are mutable (that's why you can change the person's age). You can find more information about these notions in a text tutorial and a video tutorial. Wikipedia also has some (more technical) information. An example illustrates the difference of behavior between mutable and immutable - answer by EOL
In general I've found Numpy/Scipy follow these; more importantly they tell you explicitly in the docs what is happening.
For example
np.random.shuffle
asks for an input array and returns None
while np.random.permutation
returns an array. You can clearly see which one returns a value versus doesn't here.
Simiarly arrays have pass-by-reference semantics and in general I find Numpy/Scipy
to be very efficient.
I think it's fair to say that if it's faster to use pass-by-reference
they will. As long as you use the functions the way the docs say, you shouldn't have significant problems with regards to speed.
is there any type in specific you are asking about?