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

**URL:** <https://numba.discourse.group/t/call-njit-function-with-nested-list-argument-from-a-class-method/441>\
**Category:** Support: How do I do ...?\
**Created:** [January 17, 2021, 6:08pm UTC](https://numba.discourse.group/t/call-njit-function-with-nested-list-argument-from-a-class-method/441 "2021-01-17T18:08:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arthur](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/arthur/32/203_2.png) [@Arthur](https://numba.discourse.group/u/Arthur)\
**Post date:** [January 17, 2021, 6:08pm UTC](https://numba.discourse.group/t/call-njit-function-with-nested-list-argument-from-a-class-method/441/1 "2021-01-17T18:08:11Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![luk-f-a](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/luk-f-a/32/56_2.png) [@luk-f-a](https://numba.discourse.group/u/luk-f-a)\
**Post date:** [January 17, 2021, 8:39pm UTC](https://numba.discourse.group/t/call-njit-function-with-nested-list-argument-from-a-class-method/441/2 "2021-01-17T20:39:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Arthur](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/arthur/32/203_2.png) [@Arthur](https://numba.discourse.group/u/Arthur)\
**Post date:** [January 17, 2021, 8:45pm UTC](https://numba.discourse.group/t/call-njit-function-with-nested-list-argument-from-a-class-method/441/3 "2021-01-17T20:45:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![luk-f-a](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/luk-f-a/32/56_2.png) [@luk-f-a](https://numba.discourse.group/u/luk-f-a)\
**Post date:** [January 17, 2021, 9:01pm UTC](https://numba.discourse.group/t/call-njit-function-with-nested-list-argument-from-a-class-method/441/4 "2021-01-17T21:01:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Arthur](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/arthur/32/203_2.png) [@Arthur](https://numba.discourse.group/u/Arthur)\
**Post date:** [January 17, 2021, 10:10pm UTC](https://numba.discourse.group/t/call-njit-function-with-nested-list-argument-from-a-class-method/441/5 "2021-01-17T22:10:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![luk-f-a](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/luk-f-a/32/56_2.png) [@luk-f-a](https://numba.discourse.group/u/luk-f-a)\
**Post date:** [January 18, 2021, 8:27pm UTC](https://numba.discourse.group/t/call-njit-function-with-nested-list-argument-from-a-class-method/441/6 "2021-01-18T20:27:37Z")

</div>

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](https://matthewrocklin.com/blog/work/2018/02/28/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
