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

NumPy Trac numpy-tickets@scipy....
Thu Jul 14 20:36:37 CDT 2011


#533: numpy.trace is slow for small dimensions
-------------------------------+--------------------------------------------
 Reporter:  pv                 |       Owner:  pv   
     Type:  enhancement        |      Status:  new  
 Priority:  normal             |   Milestone:  2.0.0
Component:  numpy.core         |     Version:  none 
 Keywords:  trace performance  |  
-------------------------------+--------------------------------------------

Comment(by jpeel):

 Here's the demo script:
 {{{
 import numpy as N
 import timeit

 print N.__version__
 print timeit.Timer('x.diagonal(axis1=1, axis2=2)',
                     "import numpy as N; x = N.zeros((1000, 4,
 4))").timeit(500)
 print timeit.Timer('x[:, xrange(4), xrange(4)]',
                     "import numpy as N; x = N.zeros((1000, 4,
 4))").timeit(500)
 }}}
 outputs
 {{{
 2.0.0.dev-6fdfd9c
 1.12645506859
 0.0709300041199
 }}}

-- 
Ticket URL: <http://projects.scipy.org/numpy/ticket/533#comment:8>
NumPy <http://projects.scipy.org/numpy>
My example project


More information about the NumPy-Tickets mailing list