我尝试在一个需要一个毕斯兰数组的函数中使用int,对于第二个arg,使用一个以ints的元组为键,以一个int作为值的dict:
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 ,我得到了以下错误:
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发布于 2016-02-06 21:14:59
从您的回溯来看,您似乎正在导入sys。在这种情况下,pythran试图获得导入模块的源代码来编译它。因为sys是一个内置模块,所以它会失败。
https://stackoverflow.com/questions/35240168
复制相似问题