[Numpy-discussion] avoiding the matrix copy performance hit

Bill Baxter wbaxter at gmail.com
Mon Feb 13 18:27:04 CST 2006


On 2/14/06, Tim Hochberg <tim.hochberg at cox.net> wrote:
>
> Bill Baxter wrote:
>
> > *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?
>
> You could try using copy=False:


Lovely.  That does the trick.  And the syntax isn't so bad after defining a
little helper like:

   def matr(a): return mat(a,copy=False)


>>> t1.timeit(100)
> 3.6538127052460578
> >>> t2.timeit(100)
> 3.6567186611706237
>
> I'd also like to point out that your computer appears to be much faster
> than mine.



Duly noted.  :-)


-tim



--Bill
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060213/cb2b4a25/attachment-0001.html 


More information about the Numpy-discussion mailing list