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

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.

主站蜘蛛池模板: 海林市| 利辛县| 海安县| 通城县| 遂平县| 浦县| 黔江区| 郸城县| 五莲县| 临海市| 视频| 积石山| 镇安县| 岳阳市| 恩施市| 大宁县| 德州市| 乌鲁木齐县| 榆林市| 大关县| 文成县| 大港区| 平邑县| 德令哈市| 甘孜县| 监利县| 屏东县| 太仆寺旗| 松阳县| 项城市| 通海县| 两当县| 鹤岗市| 星子县| 甘肃省| 靖边县| 灵寿县| 乌拉特后旗| 崇阳县| 阳谷县| 台东县|