【问题标题】:time dtype in numba-Using time attribute in Numba jitclass spec/ signaturenumba 中的时间 dtype-在 Numba jitclass 规范/签名中使用时间属性
【发布时间】:2021-04-21 08:54:48
【问题描述】:

我正在使用 Numba、jitclass 来提高我的执行时间。 我正在尝试使用 jitclass 装饰器在 myClass 中指定时间 dtype。 我尝试了时间、日期时间、字符串、float64/32、numba.NPD​​attime 等,但出现错误。在文档中找不到任何内容。 我的代码是......

spec = [ ('currtm',datetime.time)]

@jitclass(spec)
class myClass(object):
    def __init__(self): #
        
        self.currtm = time.time()

简单地说,我需要一个 numba 数据类型作为 python 'time' 或 'datetime' 返回值。我检查了 ans time 方法返回 float 但 numba 对此不友好。 我得到的错误说 "TypeError: spec 值应该是 Numba 类型实例,得到 "

问题是,在他们的文档中看不到时间的 Numba 类型实例?在旧版本中有一些提示,但似乎它们已被弃用。 知道怎么做吗?谢谢

【问题讨论】:

    标签: python-3.x time jit numba specs


    【解决方案1】:

    已检查,Numba 尚不支持。所以我必须使用 objemode 或 ctypes https://github.com/numba/numba/issues/4003

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-21
      • 2016-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多