Cython 纯 python 模式
Cython pure python mode
我有一个简单的 test.py
文件,我想在其中使用 Cython 添加类型。为了保持 python 解释器兼容,我使用纯 python 模式。我补充说:
import cython
然后尝试通过以下方式定义类型:
d = cython.declare(cython.dict)
然后 Eclipse 中的 python 解释器在这一行给我一个错误:
AttributeError: 'module' object has no attribute 'dict'
我错过了什么?当我将 test.py 重命名为 test.pyx 时它可以工作,但我想将其保留为 .py 文件以便能够将其导入其他 python 文件。
只需使用d = cython.declare(dict)
我有一个简单的 test.py
文件,我想在其中使用 Cython 添加类型。为了保持 python 解释器兼容,我使用纯 python 模式。我补充说:
import cython
然后尝试通过以下方式定义类型:
d = cython.declare(cython.dict)
然后 Eclipse 中的 python 解释器在这一行给我一个错误:
AttributeError: 'module' object has no attribute 'dict'
我错过了什么?当我将 test.py 重命名为 test.pyx 时它可以工作,但我想将其保留为 .py 文件以便能够将其导入其他 python 文件。
只需使用d = cython.declare(dict)