Definition of def, cdef and cpdef in cython
问题 I'd like to know the difference between def , cdef and cpdef when I declare a function. The difference between def and the others it's more or less clear. And I've also seen that sometimes it's added the return type in the declaration ( cdef void/double/int... name ) and sometimes not. I'd also like to know how to declare a string variable in cython, as I didn't know it, I declared it as object. 回答1: def declares a function in Python. Since Cython is based on C runtime, it allows you to use