[Numpy-tickets] [NumPy] #594: Major slowdown when mixing array with Python's list

NumPy numpy-tickets@scipy....
Sat Oct 20 08:57:29 CDT 2007


#594: Major slowdown when mixing array with Python's list
------------------------+---------------------------------------------------
 Reporter:  Boris       |       Owner:  somebody
     Type:  defect      |      Status:  new     
 Priority:  normal      |   Milestone:          
Component:  numpy.core  |     Version:  1.0.2   
 Severity:  normal      |    Keywords:          
------------------------+---------------------------------------------------
 I encountered a major slowdown every time I use a simple Python list with
 an array function. Here is an example which occurs quite often in my code:
 {{{
 t1 = Timer(setup='from numpy import *; x=arange(1,100);
 k=array([97,43,3,6,23,0])', stmt='x[k]')
 t1.timeit(10000)
 =0.029493949996

 t2 = Timer(setup='from numpy import *; x=arange(1,100);
 k=[97,43,3,6,23,0]', stmt='x[k]')
 t2.timeit(10000)
 =0.177627355842
 }}}
 I would expect that t2 is as fast as t1.
 Using an array instead of the list is also no option since I create this
 index lists very often and
 {{{
 k=[97,43,3,6,23,0]
 }}}
 is a lot faster than
 {{{
 k=array([97,43,3,6,23,0])
 }}}
 This slowdown also occurs with other functions, e.g. sum, sort.

-- 
Ticket URL: <http://scipy.org/scipy/numpy/ticket/594>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list