我尝试使用numba运行以下代码但收到错误:
from numba import jit
@jit(nopython=True)
def create_card_deck():
values = "23456789TJQKA"
suites = "CDHS"
Deck = []
[Deck.append(x + y) for x in values for y in suites]
return Deck
create_card_deck()
感谢任何导致此错误的建议:
'DataFlowAnalysis' object has no attribute 'op_STORE_DEREF'
答案 0 :(得分:5)
这里有两个问题 - 更基本的问题是numba
在nopython
模式下不支持字符串
@jit(nopython=True)
def create_card_deck():
values = "23456789TJQKA"
suites = "CDHS"
return values
In [4]: create_card_deck()
---------------------------------------------------------------------------
NotImplementedError : Failed at nopython (nopython mode backend)
cannot convert native str to Python object
该特定错误是因为在nopython模式下目前也不支持列表推导。