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

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.

主站蜘蛛池模板: 乌拉特后旗| 龙山县| 融水| 昌黎县| 新野县| 偃师市| 抚顺市| 大余县| 德惠市| 赤峰市| 龙岩市| 岱山县| 潍坊市| 长岭县| 安庆市| 鄂尔多斯市| 沙田区| 宣城市| 湖州市| 永德县| 长顺县| 厦门市| 措勤县| 盈江县| 衡阳市| 冀州市| 洪湖市| 扎鲁特旗| 邛崃市| 东乡| 邹城市| 西宁市| 寿宁县| 大方县| 遂平县| 平罗县| 长宁区| 井研县| 织金县| 海晏县| 财经|