28 Nov 23:04
converting c float array to numpy array or python list
From: Rich E <reakinator <at> gmail.com>
Subject: converting c float array to numpy array or python list
Newsgroups: gmane.comp.programming.swig
Date: 2008-11-28 22:08:53 GMT
Subject: converting c float array to numpy array or python list
Newsgroups: gmane.comp.programming.swig
Date: 2008-11-28 22:08:53 GMT
Hi all,
So I have a nice C library wrapped in python and I'd like to start
doing some plots of things in python... the problem is the data is all
stuck in C arrays. I'm sure this is a common problem, but I have not
found an elegant solution. Right now I have a help function that will
return one member of the C array, such as:
%inline %{
float getFloat(float *array, int index)
{
return array[index];
}
%}
But how would I go about returning a python list of the entire array,
or even better, an NumPy array?
My thoughts are that I will have to convert between C arrays and
python types (list or NumPy) quite often, probably at a refresh rate
suitable for animation. Any advice?
regards,
Rich
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
(Continue reading)
RSS Feed