i am learning Cython and now experimenting with it. I tried the basic cdef class sample program and it works perfectly.
Now what i want to do is have a mix of cdef and non cdef mix of attributes in the cdef class type, something like this
cdef class Context:
cdef public int byteIndex, bitIndex
def __init__(self, msg = "", msg_len = 0):
self.msg = msg
self.msg_len = msg_len
self.byteIndex = 0
self.bitIndex = 7
but as soon as i instantiate the object i get error
!! AttributeError: 'c_asnbase.Context' object has no attribute 'msg'
Does this mean once you define a python class with cdef all self.* attributes have to be cdef defined?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…