I want to access a C function that returns a struct containing double arrays (where the lengths of these arrays is given by other int members of the struct) from python. The dec
You could always write helper functions that take an "element *" and return the element you seek:
double element_get_weight(const element *elt, unsigned n) {
assert(n < elt->ngi); /* or similar */
return elt->weight[n];
}
If you need to modify as well as read, you will want separate "getters" and "setters", of course.
SWIG should be able to wrap all of these easily and expose them to Python.
Performance might not be great, but probably no worse than the alternatives.