我有这样的设置:
def foo(handle):
"""handle should be of type ctypes.c_void_p"""
@numba.cfunc("void()")
def bar():
# other_function has signature void(numba.types.voidptr)
other_function(handle)
我需要能够捕获句柄值并返回一个cfunc,将其编译为常量。否,返回的cfunc不能将句柄作为参数
如果我这样做,我可以让它以常量的形式编译,但它的类型是Literal[int](123456789)
,不能用作voidptr
来调用other_function
def foo(handle):
"""handle should be of type ctypes.c_void_p"""
handle_val = handle.value
@numba.cfunc("void()")
def bar():
# other_function has signature void(numba.types.voidptr)
other_function(handle_val)
我确信我一定是错过了在Numba的一些简单的铸造设施来解决这个问题,但出于某种原因,我的谷歌搜索结果一无所获!显而易见的numba.types.voidptr(123456789)
API并不存在
我怎样才能做到这一点,通常来说,我怎样才能在numba.types
类型之间进行强制转换?我希望有一个如此明显的解决方案,以至于这个问题令人尴尬
目前没有回答
相关问题 更多 >
编程相关推荐