Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced content levelIntermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
不使用 Python C API 擴充 Python
|
759
不使用 Python C API 擴充 Python
除了 C 以外,你還能以其他的傳統編譯語言編寫 Python 擴充功能。就
Fortran 而言,我們推薦Pearu Peterson F2PY
https://pypi.python.org/
pypi/F2PY/2.45.241_1926
)。 它現在是 NumPy
http://www.numpy.org/
)的一
部分,因為 Fortran 經常用於數值處理(numeric processing)。若是,如建
議的,你安裝了
numpy
,那你就不需要分別安裝
f2py
對於C++,你當然可以使用與C 相同的做法(必要時加上
extern
"C"
)。還存在許多 C++ 限定的替代做法,但在它們之中,SIP
https://
riverbankcomputing.com/sofware/sip/intro
)看起來是仍然持續被維護且受到
支援的唯一一個。
一個熱門的替代做法是 Cython
http://cython.org/
),它是專注於從類似
Python 的語法產生 C 程式碼的一個「Python 方言(Python dialect)」,
有一些附加功能得以精確指定 C 層級那邊的事情。我們高度推薦它,並在
後面的「Cython」中涵蓋它。
還有另外一個替代做法是 CFFI
https://pypi.python.org/pypi/cffi
),源於
PyPy 專案,也能完美地與它搭配使用 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

測試驅動開發|使用 Python

測試驅動開發|使用 Python

Harry J.W. Percival
Linux 内核观测技术BPF

Linux 内核观测技术BPF

David Calavera, Lorenzo Fontana

Publisher Resources

ISBN: 9789864766819