我正在尝试使用 boost::python 将 Python 类移植到 C++,希望加快 Python 应用程序的执行(我移植到 C++ 的类占应用程序执行时间的约 30%)。
原始 Python 类的 init 如下所示:
class PyClass(object):
def __init__(self, child):
child.set_parent(self)
...
如何在 C++ 构造函数中复制它?
如果我有一个 C++ 类:
class CClass
{
// to get input args that match the Python class I need
CClass(boost::python::object &child)
{
// but how do I get the boost::python::object self
// as I only have *this in C++ ?
CClass& c = boost::python::extract<CClass&>(child);
c.set_parent(self);
}
...
}
谢谢,马克