作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想用 numba.typed.List
(将其称为 List
)传递到我的函数中,该函数被包裹在 njit
中.然而这个List
应该从现有的 python 列表创建。
当我看着 documentation这似乎是您创建 List
的方式是初始化它,然后向它追加元素。但是,这需要您遍历 python 中已经存在的列表,这对于大型列表来说似乎效率低下。
例如:
from numba.typed import List
numba_list = List()
py_list = ["a", "b", "c"]
for e in py_list:
numba_list.append(e)
In [17]: numba_list[0]
Out[17]: 'a'
Is there a way to set a
List
to the values of a python list without explicitly looping over the python list ?
numba.__version__
= '0.47.0'
最佳答案
我正在研究 numba 0.49.1,您可以在其中通过构造传递列表。
py_list = [2,3,5]
number_list = numba.typed.List(py_list)
关于python - 创建一个 numba 类型列表而不遍历 python 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60186698/
我是一名优秀的程序员,十分优秀!