【问题标题】:Cython pure python modeCython 纯python模式
【发布时间】:2016-02-24 07:22:52
【问题描述】:

我有一个简单的test.py 文件,我想在其中使用 Cython 添加类型。为了保持 Python 解释器兼容,我使用纯 Python 模式。我补充说:

import cython

然后尝试通过以下方式定义类型:

d = cython.declare(cython.dict)

然后Eclipse中的python解释器在这一行给我一个错误:

AttributeError: 'module' 对象没有属性 'dict'

我错过了什么?当我将 test.py 重命名为 test.pyx 时,它可以工作,但我想将其保留为 .py 文件以便能够将其导入其他 python 文件中。

【问题讨论】:

  • 行得通!应在 cython 文档中提及。如果你把它写成答案,我可以接受它

标签: python cython


【解决方案1】:

只需使用d = cython.declare(dict)

【讨论】:

    猜你喜欢
    • 2014-07-10
    • 1970-01-01
    • 2020-02-25
    • 1970-01-01
    • 2013-06-06
    • 2014-03-06
    • 1970-01-01
    • 1970-01-01
    • 2014-02-18
    相关资源
    最近更新 更多