0

我尝试在需要数组的函数中使用Pythranint ,而对于第二个 arg a dict,其元组为intsas 键和intas 值:

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
4

1 回答 1

2

从您的回溯中,您似乎正在导入sys. 在这种情况下,pythran 会尝试获取导入模块的源代码来编译它。作为sys一个内置模块,它失败了。

于 2016-02-06T21:14:59.003 回答