I suspect there is an easy answer to this, but I need some help getting started with Cython. I have an existing C++ code base which I want to expose to Python via Cython. For ea
You are returning a C++ object in a python function that is allowed to return python objects only:
def clone(self):
return self.thisptr.clone()
Make it this:
cdef _Object clone(self) except *:
return self.thisptr.clone()
But it depends on what you're trying to do, you probably want to return Object and not _Object, so I would modify it this way:
cdef class Object:
cdef _Object thisobj
cdef _Object *thisptr
def __cinit__(self, Object obj=None):
if obj:
self.thisobj = obj.thisobj.clone()
self.thisptr = &self.thisobj
def __dealloc__(self):
pass
def clone(self):
return Object(self)