Pyhonにクラスオブジェクトを返す

2018/04/22

Cython[test.pyx]

cdef class Test:
    cdef int no
    cdef object pyobj

    def __cinit__(self,obj):
        self.no = 5
        self.pyobj = obj

    def get(self):
        self.pyobj.no = self.no
        return self.pyobj


Python

import test

class Hoge:
    def __init__(self):
        self.no = 1

hoge = Hoge()

t = test.Test(hoge)
print(t.get().no)


Cython: how to make an python object as a property of cython class
https://stackoverflow.com/questions/21012348/cython-how-to-make-an-python-object-as-a-property-of-cython-class