在“experimental_cpp_class_def”功能中,您可以在Cython(https://github.com/cython/cython/blob/master/tests/run/cpp_classes_def.pyx)中编写C ++类,是否有初始化列表的语法?这似乎有必要控制在继承的类中调用哪些构造函数。
C ++“myclass.h”:
namespace myclass
{
class MyClass {
MyClass() { };
MyClass(int x) { };
};
用Cython:
cdef extern from "myclass.h" namespace "myclass":
cdef cppclass MyClass:
MyClass()
MyClass(int x)
cdef cppclass SubClass(MyClass):
def __init__(int x):
# Implicitly calls MyClass::MyClass(), but would like to
# call MyClass::MyClass(x)
pass