Cython 是一种把 Python 与 C/C++ 结合的编程语言与编译器工具链:你可以写“接近 Python 语法”的代码(常见为 .pyx),通过静态类型声明与编译生成 C 扩展模块,从而显著提升运行速度,并更方便地调用 C/C++ 库。(它也常被用来加速数值计算、循环密集型代码与科学计算项目。)
/ˈsaɪθɑːn/
Cython can speed up tight loops in Python.
Cython 可以加速 Python 中的紧密循环(耗时循环)。
By adding type annotations and compiling with Cython, the team reduced runtime from minutes to seconds while still keeping most of the code Python-like.
通过添加类型声明并用 Cython 编译,团队把运行时间从几分钟降到几秒,同时仍然保留了大部分接近 Python 的代码风格。
Cython 是一个混成词(portmanteau),通常理解为 “C + Python”:强调它把 C 语言的性能/编译优势与 Python 的易用语法结合在一起。该项目与 Python 生态紧密相关,常用于构建高性能扩展与科学计算组件。