I am trying to speed up my Python code with Cython, and so far it is working great. I am having however one single problem: dealing with lists.
Using cython -a myscript.pyx
, I can see that the only parts of my code that call Python routines are when I'm dealing with lists.
For example, I have a numpy array (sel1
) that I need to split like this:
x1 = numpy.array([t[0] for t in sel1])
y1 = numpy.array([t[1] for t in sel1])
z1 = numpy.array([t[2] for t in sel1])
and I have no idea how to speed this up with Cython.
Another occurence is when using list/array indexes, like this:
cdef numpy.ndarray[DTYPE_t, ndim=2] init_value_1 = coords_1[0], init_value_2 = coords_2[0]
I am aware that what takes time is the Python routines that are used to access the parts of the lists I need. I currently have no idea how to speed this up though.