|
From: Ryan K. <rya...@gm...> - 2006-02-14 02:13:27
|
You both seem to have cooler computers than I do:
In [19]: t1.timeit(100)
Out[19]: 4.9827449321746826
In [20]: t2.timeit(100)
Out[20]: 4.9990239143371582
On 2/13/06, Tim Hochberg <tim...@co...> wrote:
> Bill Baxter wrote:
>
> > Is there anyway to get around this timing difference?
> > *
> > >>> import timeit
> > ** >>> t1 =3D timeit.Timer("a =3D zeros((1000,1000),'d'); a +=3D 1.;",
> > 'from numpy import zeros,mat')
> > ** >>> t2 =3D timeit.Timer("a =3D mat(zeros((1000,1000),'d')); a +=3D
> > 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?
>
> You could try using copy=3DFalse:
>
> >>> import timeit
> >>> t1 =3D timeit.Timer("a =3D zeros((1000,1000),'d'); a +=3D 1.;", 'fr=
om
> numpy import zeros,mat')
> >>> t2 =3D timeit.Timer("a =3D mat(zeros((1000,1000),'d'), copy=3DFalse)=
; a
> +=3D 1.;", 'from numpy import z
> eros,mat')
> >>> 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.
>
> -tim
>
>
> >
> > 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
>
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log fi=
les
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D103432&bid=3D230486&dat=
=3D121642
> _______________________________________________
> Numpy-discussion mailing list
> Num...@li...
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
|