I am trying to learn a little bit of cython so I can make my code faster. I started by specifying cython functions, but as you can see this has lead to errors. I am slowly understanding it except for this specific error I am getting. I define int type variables In the init function of the class. This works fine without cython, but when I try to cythonize the class it gives me an attribute error. I understand right now that cdef is only used when you can access the class/func from inside your code , and I am doing this.
cdef class Renamednotclassname:
def __init__(self, var1, var2):
cdef int self.rs = 0
cdef int self.rl = 0’
This is the portion that is giving me issues, which does not make sense to me because I can define a cdef integer in another function from the same class just fine.
AttributeError: 'cythonfile.classname' object has no attribute 'rs'
I have a main function that calls all of my internal classes and functions and I call the main function from an external file using an import. I have renamed all of my classes and functions and vars (not a problem with the names). The attribute error is saying file.class object has no attribute self.rs. My question is why does this work in native python but not cython and how can I fix this?