Numba Array of Lists

I’m working for a while with numba, but the types are still difficult for me. In the actual problem, I need lists. I know, that all works better with numpy arrays, but it is not evitable, that the array has different lengths, for example np.array([[1,2],[3,4,5]). Then, Numpy tells me to use dtype=object, if I really want to do this. But numba wants to know the type too, and I don’t know how to specify this type. I think, it should be something like types.Array(types.List,1,‘C’), but this doesn’t work. Can anyone help with this problem?

hi @Hanni-ui for arrays of uneven lengths you should consider the library “awkward array” (Documentation — Awkward Array documentation). It allows you to work, inside and outside Numba, with arrays of uneven length while keeping as much as possible the numpy API.

Hope it helps,
Luk

I do not think it is possible to make NumPy arrays of lists in Numba.

Hi - please see if How to pass a Numpy array of lists in @guvectorize function? applies.

I guess he could work with a list of arrays instead.

Yes, that should work.