I have a function and I am trying to return a number and a vector of ints. What I have is
cdef func() nogil:
cdef vector[int] vect
cdef int a_number
...
return a_number, vect
but this will give errors like Assignment of Python object not allowed without gil
. Is there a workaround?
Cython has a ctuple
type http://docs.cython.org/en/latest/src/userguide/language_basics.html#types
%%cython -a -f -+
from libcpp.vector cimport vector
cdef (vector[int], double) func() nogil:
cdef vector[int] vec
cdef double d = 3.14
cdef int i
for i in range(10):
vec.push_back(i)
return vec, d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With