Cython return tuple within cdef?
<p>Hi I am trying to convert a python code into cython in order to speed up its calculation. I am trying to return multiple arrays within the cython code from a <code>cdef</code> to <code>cpdef</code>. Based on classical C, I could either use a pointer or a tuple. I decide to use tuple because the size varies. I know the following code doesn't work, any help? Thank you!</p>

<pre><code>import numpy as np
cimport numpy as np

cdef tuple funA(double[:] X, double[:] Y): 
    cdef int nX, nY, i
    nX = len(X)
    nY = len(Y)

    for i in range(nX):
        X[i] = X[i]*X[i]

    for i in range(nY):
        Y[i] = Y[i]*Y[i]

    return X,Y

cpdef Run(double[:] X, double[:] Y)
    cdef Tuple1, Tuple2 = funA(X,Y)

    # Do some calculation with Tuple1 and Tuple2 
    # Example

    cdef int i, nTuple1, nTuple2

    nTuple1 = len(Tuple1)    
    for i in range(nTuple1):
        Tuple1[i] = Tuple1[i]**2

    nTuple2 = len(Tuple2)
    for i in range(nTuple2):
        Tuple2[i] = Tuple2[i]/2

    return Tuple1, Tuple2
</code></pre>