python - 在python中使用cimport有什么优点?

标签 python indexing cython

我最近开始使用 cython 并发现它的速度快得惊人。我见过很多 cimport 模块的代码(例如 cimport numpy),但我不知道 cimport 的特殊功能是什么 import 缺乏。
为什么有些程序员对特定模块(如 numpy)同时使用 importcimport
我也想知道是否有人可以解释什么是高效索引以及如何通过导入 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/

相关文章:

python - "unresolved external symbol"- 在 Windows 上将 Cython 扩展链接到 C 库时出错

python - Django 压缩器抛出字典更新序列元素 #0 的长度为 9;需要 2 个

python - char* 的参数转换为 python 以通过 boost.python 在 C++ 中调用 python 函数

python - 同一查询的 Spark sql 版本不起作用,而普通的 sql 查询起作用

python - 赛通 "Cannot assign default value to fields in cdef classes, structs or unions"

cython - 防止cython中c文件的双重编译

python - 覆盖文件python中的标志

javascript - 在 Javascript 中设置多维对象或数组属性的值

python - 在索引地理数据框时维护地理结构

mysql - SELECT 语句不使用 possible_keys