On Sunday, September 9, 2012, Eric Firing wrote:
> Regarding the need to pre-allocate: yes, matlab is slicker in this
> regard, and every now and then there is discussion about implementing
> equivalent behavior in numpy, or in an add-on module.
>
Technically, you don´t have to preallocate the memory, but every time you
expand your array, the whole of it will be copied to a new contiguous piece
of memory. This works, but it can be slow if you do it many times, or you
are handling big data.
Using a Python list is not much more flexible, but you could use carrays
(for chunked arrays), that are structures NumPyArrays-compatible (AFAIK)
that are stored non contiguosly in memory. Adding data only needs to move
one of those small pieces, instead of the whole array.
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users