I've developed code for biopython which I would like to speed up in my own applications by adding .pxd files and compiling with cython. Along the way I added type hints as I thought this would be an improvement (actually I hoped cython would automatically use them, but this has not been the case). Now I find that the type hinted code is incompatible with the cython enhancement I intended. For example, taking the convolve_py.py example from the cython numpy tutorial:
def naive_convolve(f, g):
changing to:
def naive_convolve(f: np.ndarray, g: np.ndarray) -> np.ndarray:
when I then put
cpdef np.ndarray[np.int_t, ndim=2] naive_convolve(np.ndarray[np.int_t, ndim=2] f, np.ndarray[np.int_t, ndim=2] g)
in the corresponding .pxd file (it works for the not type-hinted case above) I get:
def naive_convolve(f: np.ndarray, g: np.ndarray) -> np.ndarray:
^
------------------------------------------------------------
convolve_py.py:4:19: Compiler crash in AnalyseDeclarationsTransform
I have the same results with simpler types in my own code. My understanding is cython should handle 3.x features and the documentation refers to type hinting, is there another approach or option I am missing? My compile line is:
cythonize -3 -i convolve_py.py convolve_py.pxd