I decided to transfer the program from Python3 to Cython, and there is such a problem. There is a python class:
class Device: def __init__(self, name, delay, tabl): self.name = name self.delay = delay self.speed_to = tabl def upd(self, u): self.speed_to.update(u) return 0
In Cython, an absolute newbie, so I translated it into a cython-class using examples I could find:
cdef class Device: cdef str name cdef long double delay cdef dict speed_to def __init__(self, str names, long double delays, dict tabls): self.name = names self.delay = delays self.speed_to = tabls cpdef upd(self, dict u): self.speed_to.update(u) return 0
It looks (for me) so that it should work, but when you access any attribute of an object like Device('name', 123456, {1:2, 2:3}).name
gives the error: AttributeError: 'cget_time.Device' object has no attribute 'name'
Indeed, the dir()
this object shows ['__class__', ...magic methods..., '__subclasshook__', 'upd']
, that is, it does not see the attributes.
What is the problem and how can I fix it?