[SciPy-user] weave.inline : resize an array in c++

Prabhu Ramachandran prabhu_r at users.sf.net
Sat Apr 15 08:51:09 CDT 2006

>>>>> "Samuel" == Samuel GARCIA <sgarcia at olfac.univ-lyon1.fr> writes:

    Samuel> Hi, how to resize a array in the c++ code with
    Samuel> weave.inline()
    Samuel> c = ones((3,6))
    Samuel> err = weave.inline(code, ['c'], type_converters=converters.blitz) 
    Samuel> print c.shape #I want (4,7) !!!

I am not sure why you'd want to do that.  Can't you resize it from
Python?  In any case, if you really must do it, take a look at the c++
code generated by weave and look at it.  You'll see that c_array is a
PyArrayObject that you can use if you want it.  However, I am not sure
what will happen if you do resize the array and are using blitz.  I
suspect something bad may happen.  Resizing the array might also
relocate the entire block of memory for the array so accessing the
older pointer will likely be disastrous.  So, you should be careful
doing this.


More information about the SciPy-user mailing list