【发布时间】:2010-08-02 03:41:10
【问题描述】:
我正在使用 Boost.Python 来扩展 python 程序的功能。 Python 脚本对原生模块进行了大量调用,所以我非常关心 python-to-cpp 类型转换和数据编组的性能。
我决定尝试通过 Python C API 以本机方式公开方法。可能有人之前已经尝试过吗?任何成功...至少在理论上?
我遇到的问题是如何将 PyObject* 转换回类实例,PyArg_parse 提供 O& 选项,但我正在寻找的只是指向内存中 C++ 对象的指针......我怎样才能在函数中得到它?
if ( PyArg_ParseTuple(args, "O", &pyTestClass ) )
{
// how to get TestClass from pyTestClass ??
}
谢谢
【问题讨论】:
标签: python performance boost native