I am trying to write a Cython function which returns an array of mpz_t (number type of integers from the gmpy2 library). I can successfully define a fixed-size array:
cpdef void pows(mpz number):
cdef:
int x
mpz_t powers[10]
for 1 <= x <= 10:
# do stuff and store in powers
however I want to be able to define a dynamic-size array of mpz_t (i.e. to start with it empty and add values to it) and then return powers from this function. When defining the return type, so far I have tried:
cpdef mpt_t pows(mpz number):
cpdef mpz_t[:] pows(mpz number):
cpdef mpz_t * pows(mpz number):
none of which have worked. Is this possible to do?
cpdeffunctions need to be callable from Python, which means that any return type must either be a Python object or just be possible to convert to a Python object.mpz_t?cdef classthat wraps anmpz_t(and return a list of them) or declare acdef classthat wraps an array ofmpz_t.