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

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.

主站蜘蛛池模板: 都安| 溧阳市| 河间市| 黄冈市| 花垣县| 泰宁县| 西贡区| 内黄县| 江安县| 双桥区| 都兰县| 扎赉特旗| 招远市| 丹东市| 凤凰县| 普定县| 邹平县| 运城市| 汽车| 密山市| 巴彦淖尔市| 克山县| 霍林郭勒市| 商丘市| 白河县| 洛川县| 九龙城区| 璧山县| 汨罗市| 澜沧| 新野县| 临夏县| 喀什市| 稷山县| 东丽区| 玛纳斯县| 施秉县| 扶沟县| 磐安县| 漳浦县| 抚松县|