Re: [C++-sig] Arrays to python

2010-01-21 Thread Ng, Enrico
, January 21, 2010 4:17 PM To: Development of Python/C++ integration Subject: Re: [C++-sig] Arrays to python On Thu, 2010-01-21 at 09:10 -0500, Ng, Enrico wrote: > I had hoped that there was something simple after seeing the numeric part in > the documentation. Well, if you're content

Re: [C++-sig] Arrays to python

2010-01-21 Thread Jim Bosch
On Thu, 2010-01-21 at 09:10 -0500, Ng, Enrico wrote: > I had hoped that there was something simple after seeing the numeric part in > the documentation. Well, if you're content with a 1-D array and speed isn't a big issue, you can just copy the elements of your array into a Python list like this:

Re: [C++-sig] Arrays to python

2010-01-21 Thread Ng, Enrico
Sent: Wednesday, January 20, 2010 8:03 PM To: cplusplus-sig@python.org Cc: Ng, Enrico Subject: Re: [C++-sig] Arrays to python On Wed, 2010-01-20 at 17:51 -0500, Ng, Enrico wrote: > I have C code similar to the following: > > float image_data[IMAGE_SIZE]; > const float *get_data() >

Re: [C++-sig] Arrays to python

2010-01-21 Thread Michele De Stefano
If you can build a wrapper function which returns a boost::numeric::ublas::vector, you can use the wrappers into the mds-utils library (http://code.google.com/p/mds-utils/ ... it's my library). If you build the doxygen documentation, you'll find a "Python C++ extensions utilities": use the "vecto

Re: [C++-sig] Arrays to python

2010-01-20 Thread Jim Bosch
On Wed, 2010-01-20 at 17:51 -0500, Ng, Enrico wrote: > I have C code similar to the following: > > float image_data[IMAGE_SIZE]; > const float *get_data() > > get_data returns a pointer to image_data. I'd like to expose get_data to > python and have it return a copy of the array in some Python

[C++-sig] Arrays to python

2010-01-20 Thread Ng, Enrico
I have C code similar to the following: float image_data[IMAGE_SIZE]; const float *get_data() get_data returns a pointer to image_data. I'd like to expose get_data to python and have it return a copy of the array in some Python type. (it is actually a 2D array of image data) In the wrapper