I have a function which allocates a cache for calculations as
function f(x::AbstractArray) cache = zeros(length(x)) # do some calculations end
I now want to call this function very often (not in parallel) so I want to pre allocate the cache and pass it to the function, e.g. as
function f(x::AbstractArray; cache=zeros(length(x))) # do some calculations end
Is this a legitimate way to do it? Can I run into some performance issues/type instabilities?
Thanks is advance!