On 13 Mar, 20:40, Tobiah <[EMAIL PROTECTED]> wrote:
> I checked out the array module today.  It claims that
> arrays are 'efficient'.  I figured that this must mean
> that they are faster than lists, but this doesn't seem
> to be the case:
>
> ################ one.py ##############
> import array
>
> a = array.array('i')
>
> for x in xrange(10000000):
>         a.append(x)


Lists are better optimized for appending to the end. Python lists are
implemented as arrays of pointers, with a few empty slots at the
end.

Arrays are contigous memory buffers. They provide faster read-write
access, particularly for chunks of data, but are slower at resizing.

I never use the array module, as NumPy is superior.










-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to