[Numpy-tickets] [NumPy] #533: numpy.trace is slow for small dimensions

NumPy numpy-tickets@scipy....
Sat Jun 2 06:27:40 CDT 2007


#533: numpy.trace is slow for small dimensions
-------------------------+--------------------------------------------------
 Reporter:  pv           |       Owner:  somebody         
     Type:  enhancement  |      Status:  new              
 Priority:  normal       |   Milestone:                   
Component:  numpy.core   |     Version:  none             
 Severity:  normal       |    Keywords:  trace performance
-------------------------+--------------------------------------------------
 numpy.trace is slow for tracing over small dimensions:
 {{{
 import numpy as N
 import timeit

 print N.__version__
 print timeit.Timer('x.trace(axis1=1, axis2=2)',
                    "import numpy as N; x = N.zeros((1000, 4,
 4))").timeit(500)
 print timeit.Timer('x[...,0,0] + x[...,1,1] + x[...,2,2] + x[...,3,3]',
                    "import numpy as N; x = N.zeros((1000, 4,
 4))").timeit(500)

 }}}
 outputs
 {{{
 1.0.3
 3.793227911
 0.0330259799957
 }}}
 It'd be nice if the performance could be improved -- there seems to be
 room for this, as the difference is 100x.

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


More information about the Numpy-tickets mailing list