官术网_书友最值得收藏!

Linking models

Linking models are extremely important when considering how we can extend or embed things in native applications. There are two main linking models for Cython:

Fully embedded Python within C/C++ code, which looks like the following screenshot:

Using this method of embedding the Python runtime into a native application means you initiate execution of code directly from any point in your C/C++ code, as opposed to the Chapter 1, Cython Won't Bite where we had to run the Python interpreter and call an import to execute native code.

For the sake of completeness, here is the import model of using Cython:

This would be a more Pythonic approach to Cython, and will be helpful if your code base is mostly Python. We will review an example of the Python lxml module, which provides a Cython backend, later in this book, and we can compare it to the native Python backend to review the speed and execution of both code bases to perform the same task.

主站蜘蛛池模板: 德化县| 杭锦旗| 上蔡县| 荃湾区| 龙岩市| 平原县| 沂源县| 海盐县| 晋城| 大邑县| 陆丰市| 都昌县| 乌拉特中旗| 合肥市| 色达县| 常熟市| 历史| 纳雍县| 泰来县| 富顺县| 扎囊县| 新化县| 玛纳斯县| 重庆市| 富阳市| 甘谷县| 扬中市| 泸州市| 甘肃省| 常德市| 喜德县| 拉孜县| 海丰县| 永城市| 余庆县| 鄂温| 灌云县| 临湘市| 邻水| 云南省| 凌云县|