extending Python - passing nested lists
Christian Meesters
meesters at uni-mainz.de
Tue Jan 29 11:00:44 EST 2008
> You didn't mention speed in your original post.
Sorry, perhaps I considered this self-evident - which it is, of course, not.
> What about using
> array.array? Unless I am mistaken, these are just a thin wrapper
> around normal C arrays.
The algorithm I want to implement requires several million floating point
operations. Neither the array-modules nor numpy's thin layer seem thin
enough for me. ;-)
> Anyway you could always convert your list
> into a c array, do lots and lots of fast calculations, then convert it
> back again to a list.
I guess I am too blind to see, but I couldn't discover a method description
like "double* PyList_toDouble". So, yes, my question is a C-API-newbie
question: What is the way to say "myCarray = SomePyMethod(InputPyList)"? Or
better, what should be here instead
static PyObject *_foo(PyObject *self, PyObject *args) {
double *v;
if (!PyArg_Parse(args, "(d)", &v))
return NULL;
to get a list as an array of doubles into 'v' (and back to Python)?
I did read the API-description, but still am lost at this point. I presume,
once I get to know the answer I'll bang my head on the table ... ;-)
Cheers
Christian
More information about the Python-list
mailing list