According to the docs, int long and float types are interpreted as c types (rather than their python equivalents).
Inside test.pxd:
import cython
cdef class Test:
cdef float attr
cdef float test(self)
and insert test.pyx:
import cython
cdef class Test:
@cython.infer_types.verbose(True)
cdef float test(self):
attr = self.attr
return attr
Cython infers attr to be a Python object and performs a PyFloat_FromDouble on attr (implying that cython really thinks self.attr is a double instead of a float as specified inside test.pxd).
Why can't cython infer self.attr to be a float? If I do "cdef float attr = self.attr" it works just fine. And, if I change the type everywhere to be double instead of float, the type inference works fine.
Currently on Cython version 3.0.0a11
Best, Trevor