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?