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 技術手冊 第三版
719
24
擴充與
內嵌標準型的 Python
CPython 執行於一個可移植(portable)的、以 C 編寫的虛擬機器(virtual
machine)之上。Python 的內建物件(built-in objects),例如數字、序列、
字典、集合,以及檔案,都是以 C 編寫的,Python 標準程式庫中的幾個模
組也是。現代平台支援動態載入(dynamic-load)的程式庫,其檔案的延
伸檔名(file extensions)在 Windows 上為
.dll
,在 Linux 上為
.so
,而在
Mac 上為
.dylib
:建置 Python 的時候就會產生這種二進位檔案。你可以用
C Python 編寫你自己的擴充模組(extension modules),使用涵蓋於本
章的 Python C API,來產生並部署動態程式庫,讓 Python 指令稿和互動工
作階段(interactive sessions)可以在之後使用
import
述句來匯入它們,如
前面「import 述句」中所涵蓋的。
擴充
extending
意味著建置出模組讓 Python 程式碼可以
import
來取用
該模組所提供的功能。
內嵌
embedding
Python 代表在以另一個語言編
寫的應用程式中執行 Python 程式碼。要讓這種執行發揮用處,Python 程式
碼必須能夠存取你應用程式的某些功能性。因此,在實務上,內嵌就代表
某個程度的擴充,以及幾個內嵌限定的作業。想要擴充 Python 的三個主要
原因可以總結如下: ...
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