[Numpy-discussion] avoiding the matrix copy performance hit
Bill Baxter
wbaxter at gmail.com
Mon Feb 13 17:49:15 EST 2006
Is there anyway to get around this timing difference?
*
>>> import timeit
** >>> t1 = timeit.Timer("a = zeros((1000,1000),'d'); a += 1.;", 'from
numpy import zeros,mat')
** >>> t2 = timeit.Timer("a = mat(zeros((1000,1000),'d')); a += 1.;",
'from numpy import zeros,mat')
>>> **t1.timeit(100)
1.8391627591141742
>>> t2.timeit(100)
3.2988266117713465
*Copying all the data of the input array seems wasteful when the array is
just going to go out of scope. Or is this not something to be concerned
about?
It seems like a copy-by-reference version of mat() would be useful. Really
I can't imagine any case when I'd want both a matrix and the original
version of the array both hanging around as separate copies. I can imagine
either 1) the array is just a temp and I won't ever need it again or 2)
temporarily wanting a "matrix view" on the array's data to do some linalg,
after which I'll go back to using the original (now modified) array as an
array again.
--bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060213/3f3abcd4/attachment.html>
More information about the NumPy-Discussion
mailing list