我最近开始使用 cython 并发现它的速度快得惊人。我见过很多 cimport
模块的代码(例如 cimport numpy
),但我不知道 cimport
的特殊功能是什么 import
缺乏。
为什么有些程序员对特定模块(如 numpy)同时使用 import
和 cimport
。
我也想知道是否有人可以解释什么是高效索引以及如何通过导入 numpy 模块来使用它?
谢谢
最佳答案
cimport =“Cython 导入”
根据documentation :
A Cython module can be split into two parts: a definition file with a
.pxd
suffix, containing C declarations that are to be available to other Cython modules, and an implementation file with a.pyx
suffix, containing everything else. When a module wants to use something declared in another module’s definition file, it imports it using the cimport statement.
关于python - 在python中使用cimport有什么优点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46032031/