<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](extending.xhtml "1. 使用 C 或 C++ 擴展 Python") | - [上一頁](../library/undoc.xhtml "未創建文檔的模塊") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - $('.inline-search').show(0); | # 擴展和嵌入 Python 解釋器 本文檔描述了如何使用 C 或 C++ 編寫模塊以使用新模塊來擴展 Python 解釋器的功能。 這些模塊不僅可以定義新的函數,還可以定義新的對象類型及其方法。 該文檔還描述了如何將 Python 解釋器嵌入到另一個應用程序中,以用作擴展語言。 最后,它展示了如何編譯和鏈接擴展模塊,以便它們可以動態地(在運行時)加載到解釋器中,如果底層操作系統支持此特性的話。 本文檔假設你具備有關 Python 的基本知識。有關該語言的非正式介紹,請參閱 [Python 教程](../tutorial/index.xhtml#tutorial-index) 。 [Python 語言參考](../reference/index.xhtml#reference-index) 給出了更正式的語言定義。 [Python 標準庫](../library/index.xhtml#library-index) 包含現有的對象類型、函數和模塊(內置和用 Python 編寫)的文檔,使語言具有廣泛的應用范圍。 關于整個 Python/C API 的詳細介紹,請參閱獨立的 [Python/C API 參考手冊](../c-api/index.xhtml#c-api-index) 。 ## 推薦的第三方工具 本指南僅介紹了作為此 CPython 版本的一部分提供的創建擴展的基本工具。 第三方工具,如 [Cython](http://cython.org/) \[http://cython.org/\] 、 [cffi](https://cffi.readthedocs.io) \[https://cffi.readthedocs.io\] 、 [SWIG](http://www.swig.org) \[http://www.swig.org\] 和 [Numba](https://numba.pydata.org/) \[https://numba.pydata.org/\] 提供了更簡單和更復雜的方法來為 Python 創建 C 和 C ++ 擴展。 參見 [Python Packaging User Guide: Binary Extensions](https://packaging.python.org/guides/packaging-binary-extensions/) \[https://packaging.python.org/guides/packaging-binary-extensions/\]“ Python Packaging User Guide ”不僅涵蓋了幾個簡化二進制擴展創建的可用工具,還討論了為什么首先創建擴展模塊的各種原因。 ## 不使用第三方工具創建擴展 本指南的這一部分包括在沒有第三方工具幫助的情況下創建 C 和 C ++ 擴展。它主要用于這些工具的創建者,而不是建議你創建自己的 C 擴展的方法。 - [1. 使用 C 或 C++ 擴展 Python](extending.xhtml) - [1.1. 一個簡單的例子](extending.xhtml#a-simple-example) - [1.2. 關于錯誤和異常](extending.xhtml#intermezzo-errors-and-exceptions) - [1.3. 回到例子](extending.xhtml#back-to-the-example) - [1.4. 模塊方法表和初始化函數](extending.xhtml#the-module-s-method-table-and-initialization-function) - [1.5. 編譯和鏈接](extending.xhtml#compilation-and-linkage) - [1.6. 在C中調用Python函數](extending.xhtml#calling-python-functions-from-c) - [1.7. 提取擴展函數的參數](extending.xhtml#extracting-parameters-in-extension-functions) - [1.8. 給擴展函數的關鍵字參數](extending.xhtml#keyword-parameters-for-extension-functions) - [1.9. 構造任意值](extending.xhtml#building-arbitrary-values) - [1.10. 引用計數](extending.xhtml#reference-counts) - [1.11. 在C++中編寫擴展](extending.xhtml#writing-extensions-in-c) - [1.12. 給擴展模塊提供C API](extending.xhtml#providing-a-c-api-for-an-extension-module) - [2. 自定義擴展類型:教程](newtypes_tutorial.xhtml) - [2.1. 基礎](newtypes_tutorial.xhtml#the-basics) - [2.2. Adding data and methods to the Basic example](newtypes_tutorial.xhtml#adding-data-and-methods-to-the-basic-example) - [2.3. Providing finer control over data attributes](newtypes_tutorial.xhtml#providing-finer-control-over-data-attributes) - [2.4. Supporting cyclic garbage collection](newtypes_tutorial.xhtml#supporting-cyclic-garbage-collection) - [2.5. Subclassing other types](newtypes_tutorial.xhtml#subclassing-other-types) - [3. 定義擴展類型:已分類主題](newtypes.xhtml) - [3.1. 終結和內存釋放](newtypes.xhtml#finalization-and-de-allocation) - [3.2. 對象展示](newtypes.xhtml#object-presentation) - [3.3. Attribute Management](newtypes.xhtml#attribute-management) - [3.4. Object Comparison](newtypes.xhtml#object-comparison) - [3.5. Abstract Protocol Support](newtypes.xhtml#abstract-protocol-support) - [3.6. Weak Reference Support](newtypes.xhtml#weak-reference-support) - [3.7. 更多建議](newtypes.xhtml#more-suggestions) - [4. 構建C/C++擴展](building.xhtml) - [4.1. 使用distutils構建C和C++擴展](building.xhtml#building-c-and-c-extensions-with-distutils) - [4.2. 發布你的擴展模塊](building.xhtml#distributing-your-extension-modules) - [5. 在Windows平臺編譯C和C++擴展](windows.xhtml) - [5.1. A Cookbook Approach](windows.xhtml#a-cookbook-approach) - [5.2. Differences Between Unix and Windows](windows.xhtml#differences-between-unix-and-windows) - [5.3. Using DLLs in Practice](windows.xhtml#using-dlls-in-practice) ## 在更大的應用程序中嵌入 CPython 運行時 有時,不是要創建在 Python 解釋器中作為主應用程序運行的擴展,而是希望將 CPython 運行時嵌入到更大的應用程序中。 本節介紹了成功完成此操作所涉及的一些細節。 - [1. Embedding Python in Another Application](embedding.xhtml) - [1.1. Very High Level Embedding](embedding.xhtml#very-high-level-embedding) - [1.2. Beyond Very High Level Embedding: An overview](embedding.xhtml#beyond-very-high-level-embedding-an-overview) - [1.3. Pure Embedding](embedding.xhtml#pure-embedding) - [1.4. Extending Embedded Python](embedding.xhtml#extending-embedded-python) - [1.5. Embedding Python in C++](embedding.xhtml#embedding-python-in-c) - [1.6. Compiling and Linking under Unix-like systems](embedding.xhtml#compiling-and-linking-under-unix-like-systems) ### 導航 - [索引](../genindex.xhtml "總目錄") - [模塊](../py-modindex.xhtml "Python 模塊索引") | - [下一頁](extending.xhtml "1. 使用 C 或 C++ 擴展 Python") | - [上一頁](../library/undoc.xhtml "未創建文檔的模塊") | - ![](https://box.kancloud.cn/a721fc7ec672275e257bbbfde49a4d4e_16x16.png) - [Python](https://www.python.org/) ? - zh\_CN 3.7.3 [文檔](../index.xhtml) ? - $('.inline-search').show(0); | ? [版權所有](../copyright.xhtml) 2001-2019, Python Software Foundation. Python 軟件基金會是一個非盈利組織。 [請捐助。](https://www.python.org/psf/donations/) 最后更新于 5月 21, 2019. [發現了問題](../bugs.xhtml)? 使用[Sphinx](http://sphinx.pocoo.org/)1.8.4 創建。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看