我尝试在需要int
数组的函数中使用Pythran,对于第二个参数,使用dict
元组ints
作为键,int
作为值:
myarray = np.array([[0, 0], [0, 1], [1, 1],
[1, 2], [2, 2], [1, 3]])
dict_with_tuples_key = {(0, 1): 1, (3, 7): 1}
告诉Pythran关于dict
的正确方法是什么?地址:
#pythran export update_dict((int, int):int dict, int[][])
def update_dict(dict_with_tuples_key, myarray):
# do something with dict_with_tuples_key and myarray
# return and updated dict_with_tuples_key
return dict_with_tuples_key
使用(int,int):int dict我得到这个错误:
File "/usr/lib/python2.7/inspect.py", line 526, in findsource
file = getfile(object)
File "/usr/lib/python2.7/inspect.py", line 403, in getfile
raise TypeError('{!r} is a built-in module'.format(object))
TypeError: <module 'sys' (built-in)> is a built-in module
从回溯来看,似乎您正在导入
sys
。在这种情况下,pythran试图获取导入模块的源代码来编译它。因为sys
是一个内置模块,所以它失败了。相关问题 更多 >
编程相关推荐