I only have a little coding experience in C, and I remember I was told that pass by reference is more efficient than pass by value since the parameters don't need to be copied. Since there is no pass by reference in Mathematica, I'm wondering if that affects the performance of function calls, especially when dealing with large data?
Answer
In Mathematica, this does not affect performance because copying does not take place most of the time. To put it simply, Mathematica implements copy-on-demand: it creates a copy of the data structure only if it is modified. Please see this answer for a more detailed explanation:
Does passing a variable with a large amount of data cost a lot of memory and time in Mathematica?
Comments
Post a Comment