Numarray append

Fernando Pérez fperez528 at yahoo.com
Sat Nov 9 17:52:06 EST 2002


Fabrizio wrote:

> Hi,
> 
> Is there a quick way to append elements to a Numarray array ?
> 
> I could not find any.

You are thinking of numarrays as python lists. They are much more like C 
arrays: homogeneous, fixed-size structures. That's why things can be done 
fast with them, but the price you pay is flexibility. If you need to grow a 
numarray, the easiest way is to allocate a new one of the desired final size, 
then copy into it the data of the original and fill in the new data as 
needed. With judicious use of take & friends all this can be done 
efficiently.

Cheers,

f.



More information about the Python-list mailing list