[Numpy-discussion] swig numpy2carray converters

Georg Holzmann grh@mur...
Tue Nov 20 08:56:44 CST 2007


Hallo!

>     E.g. in my algorithm I can have a very big internal matrix in C++ (say
>     700 MB - in fortran style). Now I want to have this matrix in numpy to
>     plot some parts of it, get some data out of it ... whatever - if I again
>     allocate an array of the same size, I am out of memory.
>     Therefore I simply used the PyArray_FromDimsAndData() function to
>     allocate the array.
> 
> 
> 
> This is why you use INPLACE typemaps that will NOT copy your data.
[...]
> Are you sure ? Because the original object is not modified, so it is 
> still the same data.

Hm ... lets consider the same example as before (one 700MB matrix in C++).
If I want to get this data with an INPLACE typemap I again have to 
allocate an 700 MB array in python, then passing it to my C++ library 
which puts in the data of it - so in the end I have to use two times 700 
MB matrices ?
(or maybe I don't understand something ;) ?)

> If what you want is to provide a view  from your C++ matrix, this is 
> different. You must either :
> - propose the array interface
> - use a Python object inside your C++ matrix (this is to be done, I've a 
> basic example in my blog)

Yes, maybe thats what I need.
Do you have a link to that blog ?

LG
GEorg


More information about the Numpy-discussion mailing list