multidimensional arrays from python to C

Chris Fonnesbeck spam at fisher.forestry.uga.edu
Wed May 29 12:27:23 EDT 2002


I am embedding some python code in C, and need to be able to take a
multidim. array from python and assign its values to a global double
array in C.  Can this python array simply be cast into a C double
type, and assigned to the array in question, or do I have to do a
multiple-nested loop to assign each element individually.  Hope this
makes sense!

For example, in C I have:

double Fall[NA][NS][NG][NC][NP], where N* are constants

and I have pulled in my python 5-dimensional array with:

parray = (PyArrayObject *)(PyEval_CallObject(pmeth,pargs));

How do I get these values into Fall?

TIA<
cjf



More information about the Python-list mailing list