Embedded jagged lists of strings

I have input data like this

data = [['foo1','bar1'],['foo2','bar2','fooz2','baz2'],['foo3']]

Ie. list of lists where in each sublist there is a different number of strings.

Is it somehow possible to send this data into an @njit function and run a double loop to make operations on this input data?

For example this

@njit
def myfunc(lst):
    a = 0
    for i in range(len(lst)):
        for j in range(len(lst[i])):
            a += 1
    return a

Is giving me an error:

TypeError: Failed in nopython mode pipeline (step: native lowering)
cannot reflect element of reflected container: reflected list(reflected list(unicode_type)<iv=None>)<iv=None>

If i use my initial example data as input

count = myfunc(data)

Hi @bkakke,

The numba.typed.List container should work for this:

from numba import njit, typed
import numpy as np

data = [['foo1','bar1'],['foo2','bar2','fooz2','baz2'],['foo3']]
typed_data = typed.List([typed.List(x) for x in data])
print(typed_data)

@njit
def myfunc(lst):
    a = 0
    for i in range(len(lst)):
        for j in range(len(lst[i])):
            a += 1
    return a

print("result", myfunc(typed_data))

docs: Supported Python features — Numba 0.54.1+0.g39aef3deb.dirty-py3.7-linux-x86_64.egg documentation

Hope this helps?