Call @njit function with nested List() argument from a class method

Hi, I’m new to this list and to Numba!
I have a networking class that inherits from a library (Twisted) and I don’t even think to try to jit it. In its datagramRecieved method, I get some part of the 3D image (coming from Lidar).
I implemented primitive denoising algorithm that compares tof (“time of flight” in ns) value in current frame to some (depth) previous frames:

@njit
def filter(row, col, tof, depth, thresh, limit, db):
    miss = 0
    for i in range(depth + 1):
        if abs(tof - db[i][row][col]) >= limit:
            miss += 1
            if miss > thresh:
                break
    return miss

Where db is initialized as nested numba.typed List[List[List[int64]]].
When a frame is received completely a FIFO is applied:

@njit
def fifoStep(db):
    mat = List()
    for _ in range(NUM_OF_ROW):
        ll = List()
        for _ in range(NUM_OF_COL):
            ll.append(65535)
        mat.append(ll)
    db.append(mat)
    del db[0]

when I try to call from the datagramRecieved method a @njit-ed function that parses the datagram and calls the above filter and fifoStep @njit-ed I get wrong indices in the db.
on the other hand it works correct w/o @njit but it is slow!

what I might been doing wrong?

hi @Arthur , just checking if I understood: with njit the function runs but returns a different result than without njit?

correct and without njit it gives the correct indexing into nested lists

could you provide a self-contained reproducer? Something one could run and see the results?

sure, please see https://bitbucket.org/arthurbe/algops
Thank you for looking into this

hi @Arthur , thanks for sharing. However, this is too much code to be able to figure out the problem. I’m sorry, but it would require a lot of debugging. Are you familiar with minimum reproducers? Craft Minimal Bug Reports

The idea is to take as much code away as possible while still producing the same error. That helps narrow down the problem. Ideally just one function call, with a synthetic input. No twisted reactor, no listening to ports, just a simple sequence of actions that reproduces the problem.

Luk