Extending Python - variable sized arrays?
tegbert at abl.med.utah.edu
Tue Oct 16 23:47:55 CEST 2001
I'm developing a native method module for Python from some existing code.
One function that I call returns an integer array that can be any size up
Returning the array as a tuple using Py_BuildValue() is a problem because,
although I can create the format string dynamically, I can't create a
dymanically sized argument list. Maybe I'm just being dense, but I'd like
to do something like this (illustrated here with a currently nonexistent
function call, Py_BuildArrayTuple()):
(arr gets allocated and loaded with 6 values)
ret = Py_BuildArrayTuple("6i",arr);
which would be the equivalent of:
ret = Py_BuildValue("iiiiii",
I can't go the Py_BuildValue() route because the problems is, the next
time around, there may be 17 or 127 elements in the array, the exact
number only to be known during runtime.
Any thoughts on how to do this?
More information about the Python-list