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
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?