my loop is too slow
Joe Strout
joe at strout.net
Tue May 11 17:48:04 EDT 1999
In article <Oc1_2.1163$G3.34761 at news14.ispnews.com>, Tim Hochberg
<hochberg at psn.net> wrote:
> >2. If you're doing something that can be expressed in linear algebra,
> >consider using the Numeric module; it is MUCH faster than standard
> >Python at such operations.
> FWIW: Taking into account Michael Haggerty's observation on that this is
> really a matrixmultiply of (c.f)(c.transpose(f)), I reimplemented the
> original loop as:
>
> from Numeric import *
> a = a + dot(c, f) * dot(c, transpose(f))
>
> This improved the speed a lot. In fact the above runs in less than a second
> on a P300 machine with len(a)=142.
>From 10 hours to less than a second! On different machines, of course,
so the two are not really comparable, but even so... this is what I
would call a "significant improvement".
Yay for Numeric!
Cheers,
-- Joe
--
,------------------------------------------------------------------.
| Joseph J. Strout Biocomputing -- The Salk Institute |
| joe at strout.net http://www.strout.net |
`------------------------------------------------------------------'
Check out the Mac Web Directory! http://www.strout.net/macweb.cgi
More information about the Python-list
mailing list