# How to check inferred numba type with nopython true

**URL:** <https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962>\
**Category:** Support: How do I do ...?\
**Created:** [October 16, 2021, 7:19am UTC](https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962 "2021-10-16T07:19:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![guzuomuse](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/guzuomuse/32/427_2.png) [@guzuomuse](https://numba.discourse.group/u/guzuomuse)\
**Post date:** [October 16, 2021, 7:19am UTC](https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962/1 "2021-10-16T07:19:04Z")

</div>

i have the question same as :  
[How to check inferred numba type with nopython true](https://stackoverflow.com/questions/47667879/how-to-check-inferred-numba-type-with-nopython-true)  
assume that we have two njit functions, one function will call another. and then use the first’s return result to create a numba type

```auto
@nb.njit()
def fn_1():
    a = np.random.randint(1, 100, size=24).reshape(4, 6)
    b = np.empty((4, 6), 'f8')
    c = np.empty((2, 8), 'i8')
    return a, b, c
    pass

```

```auto
@nb.njit()
def fn_2():
    rs = fn_1()
    numba_type=get_numba_type_from(rs)??????????????????? how could i do this?
    # my_list = nb.typed.typedlist.List.empty_list(numba_type)
    # my_list = nb.typed.typedlist.List([rs])
    # my_list.append(rs)
    pass

```

---

<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:** [October 16, 2021, 8:28am UTC](https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962/2 "2021-10-16T08:28:55Z")

</div>

hi @guzuomuse , the link seems wrong. The text says “how to check …” but the link is to a thread on testing Numba 0.53.

---

<div class="post-metadata">

**Author:** ![guzuomuse](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/guzuomuse/32/427_2.png) [@guzuomuse](https://numba.discourse.group/u/guzuomuse)\
**Post date:** [October 16, 2021, 9:11am UTC](https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962/3 "2021-10-16T09:11:29Z")

</div>

@luk-f-a thanks for inform that. modified. do you know how to get the inferred type with onpython mode as the question described? thank you

---

<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:** [October 16, 2021, 10:10am UTC](https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962/4 "2021-10-16T10:10:51Z")

</div>

From you code example above, it seems that you don’t need `typeof`. Would this do what you want?

```auto
@njit()
def fn_1():
    a = np.random.randint(1, 100, size=24).reshape(4, 6)
    b = np.empty((4, 6), 'f8')
    c = np.empty((2, 8), 'i8')
    return a, b, c
    

@njit()
def fn_2():
    rs = fn_1()
    my_list = []
    my_list.append(rs)
    return my_list

```

---

<div class="post-metadata">

**Author:** ![guzuomuse](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/guzuomuse/32/427_2.png) [@guzuomuse](https://numba.discourse.group/u/guzuomuse)\
**Post date:** [October 16, 2021, 10:44am UTC](https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962/5 "2021-10-16T10:44:22Z")

</div>

@luk-f-a the code works. but tha’t not what i want! the only thing i want here is to get the type on-the-fly programmatically .

---

<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:** [October 16, 2021, 7:20pm UTC](https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962/6 "2021-10-16T19:20:26Z")

</div>

creating a numba type cannot be done inside a jitted function. Types are a compile-time object, and they can be created in non-jitted code. They cannot be created at runtime, inside the jitted function.

I’m assuming that getting the type on-the-fly is only a means to an end. If you explain what you are trying to achieve, I might be able to suggest something that numba can do. Have you looked at the documentation of `generated_jit`?

Luk

---

<div class="post-metadata">

**Author:** ![guzuomuse](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/guzuomuse/32/427_2.png) [@guzuomuse](https://numba.discourse.group/u/guzuomuse)\
**Post date:** [October 18, 2021, 12:11am UTC](https://numba.discourse.group/t/how-to-check-inferred-numba-type-with-nopython-true/962/7 "2021-10-18T00:11:49Z")

</div>

just for learning purpose.  
let it be it ,thanks for your help.
