I am using Numba a lot to speed up many loops which cannot be vectorised and would otherwise be very slow. My questions are:
Can a Numba function create numpy arrays? I haven't found a way: functions like np.zeros don't work in Numba. What I do now is create empty arrays (initialised with zeros or NaNs) outside of Numba and passing them to my Numba function, which then fills them based on the calculation of my loop.
- Can Numba
do a deep copy of a numpy array? I often have to work on many arrays
of the same size. Numba can run
array2 = array1, but array2 becomes a reference to array1 (changing one changes the other). - When I have non-Numba functions with many inputs and many outputs, I like to create classes with no methods for inputs and outputs. This way I can run something like:
myinput.input_1= foo1
myinput.input_2 = foo2
myoutput = myfunction(myinput)
- Can Numba
do a deep copy of a numpy array? I often have to work on many arrays
of the same size. Numba can run
which is convenient when I have 20 inputs and 20 outputs. Can Numba support anything like this?