Operating on global variables in Julia is generally slower so you should 
definitely pass the array to the function. 

On Friday, October 24, 2014 7:43:53 PM UTC+3, Nils Gudat wrote:
>
> A general performance question: when writing functions that operate on a 
> large number of variables stored in arrays, is it generally better to pass 
> every array into the function or to let the function access the arrays in 
> the global space?
>
> Comparing
>
> X = rand(10000)
>
> function(a::Real)
>     (some computation involving a and the values in an array X)
> end
>
> to
>
> function(a::Real, X::Array)
>    (the same computation)
> end
>
> I found that passing the array was marginally smaller on most occasions, 
> but I'm wondering how general this result is and what it would depend on. 
> Are there any rules/best practices for this?
>

Reply via email to