array vs. list

C. Porter Bassett porter at et.byu.edu
Sat Feb 10 00:38:25 CET 2001


I have a couple of matrix/vector classes that I wrote.  The matrix is 4x4
and the vector is 4X1, just like the ones they use in OpenGL.  Anyway,
when I wrote it quick and dirty, I used all lists.  I just went back and
replaced lists with arrays where I could.  Much to my surprise, it was
about half again slower using arrays instead of lists!  I thought that
arrays were supposed to be more effecient than lists, but I guess they
aren't.  In case it would make a difference, this was done on a 400 MHZ
linux box and python 2.0

Yeah, I know that I should learn NumPy and implement it there, but one
thing at a time.

C. Porter Bassett




More information about the Python-list mailing list