The reason why I ask, is that I am afraid that this for loop slows everything down.
What do you think? 2014-05-05 18:41 GMT+02:00 Edward d'Auvergne <[email protected]>: > This is not Python specific though :) As far as I know, C uses > pass-by-value for arguments, unless they are arrays or other funky > objects/functions/etc.. This is the same behaviour as Python. > Pass-by-reference and pass-by-value is something that needs to be > mastered in all languages, whether or not you have pointers to play > with. > > Regards, > > Edward > > > > On 5 May 2014 18:30, Troels Emtekær Linnet <[email protected]> wrote: >> This reminds me: >> >> http://combichem.blogspot.dk/2013/08/you-know-what-really-grinds-my-gears-in.html >> >> 2014-05-05 17:52 GMT+02:00 Edward d'Auvergne <[email protected]>: >>> Hi, >>> >>> This is an important difference. In the first case (back_calc[i] = >>> Minty[i]), what is happening is that your are copying the data into a >>> pre-existing structure. In the second case (back_calc = Minty), the >>> existing back_calc structure will be overwritten. Therefore the >>> back_calc structure in the calling code will be modified in the first >>> case but not the second. Here is some demo code: >>> >>> def mod1(x): >>> x[0] = 1 >>> >>> def mod2(x): >>> x = [3, 2] >>> >>> x = [0, 2] >>> print(x) >>> mod1(x) >>> print(x) >>> mod2(x) >>> print(x) >>> >>> I don't know of a way around this. >>> >>> Regards, >>> >>> Edward >>> >>> >>> On 5 May 2014 17:42, Troels Emtekær Linnet <[email protected]> wrote: >>>> Hi Edward. >>>> >>>> In the library function of b14.py, i am looping over >>>> the dispersion points to put in the data. >>>> >>>> for i in range(num_points): >>>> >>>> # The full formula. >>>> back_calc[i] = Minty[i] >>>> >>>> Why can I not just set: >>>> back_calc = Minty >>>> >>>> _______________________________________________ >>>> relax (http://www.nmr-relax.com) >>>> >>>> This is the relax-devel mailing list >>>> [email protected] >>>> >>>> To unsubscribe from this list, get a password >>>> reminder, or change your subscription options, >>>> visit the list information page at >>>> https://mail.gna.org/listinfo/relax-devel _______________________________________________ relax (http://www.nmr-relax.com) This is the relax-devel mailing list [email protected] To unsubscribe from this list, get a password reminder, or change your subscription options, visit the list information page at https://mail.gna.org/listinfo/relax-devel

