
Jan. 16, 2009
5:31 p.m.
On Fri, Jan 16, 2009 at 2:34 PM, Philipp Heuser <philipp@achtziger.de> wrote:
Hi all,
I am trying to return an array from C to Python. Since it is of variable size,
return Py_BuildValue("[f,f,f]", array[0], array[1], array[2]);
does not help. How do I do that?
Create an empty list (PyList_New(0)) and then append (PyList_Append) items (PyFloat_FromDouble) as you loop over this array variable. I'm considering for some reason you don't know the size of this variable, so it has a sentinel in the end, but if it is not the case you can create a list with its final size and then use PyList_SetItem.
Any help is appreciated, kind regards Philipp
-- -- Guilherme H. Polo Goncalves