Files
ailearning/docs/da/092.md
2020-10-19 21:04:12 +08:00

27 lines
948 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 简介
## 使用 Python 和另一种语言混编的好处
至少有以下四个原因:
1. `Best of both worlds` - 结合两种语言的优点:已经优化和测试过的代码库 + Python 的灵活
2. `Python as glue` - **Python** 作为连接的桥梁,将很多其他语言的模块结合到一个大型程序中
3. `Speed up Python` - 使用一个更快的语言帮助加速 **Python**
4. `Division of labor` - 各司其职,让各个语言做各自更擅长的事情,例如 **Fortran** 进行数组计算,**Python** 处理测试文件读写文本处理数据整理GUI 生成HTTP 服务等等。
## 语言扩展工具
### 打包已有的代码和其他语言的库
* 使用手写的扩展模块
* `Cython` - **C/C++**
* `SWIG` - **C/C++**
* `f2py` - **Fortran**
* `ctypes` - 其他语言库
### 加速 Python
* 使用手写的扩展模块
* `Cython`
* `Weave`
* `Shedskin` 和其他模块