rohanp
rohanp

Reputation: 630

Cython function returning pointer without GIL error

I dont understand why this does not compile. _svd returns a double*, and I am assigning it to a double*.

Error Message: Coercion from Python not allowed without the GIL

cpdef svd(A_f, m, n):
    cdef double *S_p

    with nogil:
        S_p = _svd(A_f, m, n)

    return <double[:min(m, n)]> S_p

cdef double* _svd(double[:] A_f, int m, int n) nogil:
    #code removed bc it is long

Edit: It works with the GIL, but I want to call it without the GIL.

Upvotes: 1

Views: 396

Answers (1)

colinfang
colinfang

Reputation: 21767

Try this

cpdef svd(A_f, int m, int n):

    cdef double *S_p

    cdef double[:] abc = A_f

    with nogil:
          S_p = _svd(abc , m, n)

Upvotes: 1

Related Questions