This is my first try at Julia, so please forgive me if this sound trivial to you. My Julia code is already performing way better than my Python code, but I am left with a question concerning typing.
For a scientific program I am working with a multitude of arrays that are type-stable and of fixed dimensionality. The program aims to update these arrays by a mathematically non-trivial scheme in order to minimize an energy function. I have defined these arrays in the global scope by
const A = Array{Complex{Float32}}(dim)
where dim
is the dimensionality. I noticed adding the const
caused a my calculations to speed up considerably (x3 faster). Subsequently, the contents of these arrays are initialized and updated in functions by A[:] =...
.
Is defining type-stable arrays of fixed dimensionality as const
s globally, and updating by accessing them as A[:]
considered bad practice?
My best shot at an alternative method would be typing the input arguments of all my functions and passing a lot of variables around. Would this be more desirable?