To build Python extension modules, SWIG uses a layered approach in which parts of the extension module are defined in C and other parts are defined in Python. The C layer contains low-level wrappers whereas Python code is used to define high-level features.
This layered approach recognizes the fact that certain aspects of extension building are better accomplished in each language (instead of trying to do everything in C or C++). Furthermore, by generating code in both languages, you get a lot more flexibility since you can enhance the extension module with support code in either language.
When -builtin is used, the pure python layer is stripped off. Each wrapped class is turned into a new python built-in type which inherits from SwigPyObject, and SwigPyObject instances are returned directly from the wrapped methods.
斯威格是什么?
<^ >Simplified Wrapper and Interface Generator(SWIG)是一种开源软件工具,用于连接C或C++编写的库与脚本语言,如Python。一个著名的替代品是Boost。{a2}的目标是完成相同的任务。在使用SWIG创建一个在C/C++中开发的Python库(用于与现有C/C++库的互操作性,或者在性能上获得增益,或者其他什么)。在
引用SWIG documentation:
什么是SwigPyObject对象?
SwigPyObject
对象在SWIG documentation中的“Python类接口的进一步细节”主题中描述。在这个对象是一个实现细节。它由以下C结构定义:
< P> A^ { CD1>}对象存储C++对象的实例:pickle文件
pickle文件中包含的数据包含一个
SwigPyObject
对象,但是您的解释器不知道如何反序列化它。您需要检查您的VielalEnv包含Python/C++库,它提供您的泡菜对象。在相关问题 更多 >
编程相关推荐