How to check inferred numba type with nopython true

i have the question same as :
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

@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

@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

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

@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

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

@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

@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 .

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

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