[Tutor] improving speed using and recalling C functions
Gabriele Brambilla
gb.gabrielebrambilla at gmail.com
Fri Apr 11 15:20:07 CEST 2014
Hi Danny,
I'm quiet impressed.
the program takes near 30 minutes instead of more than 8 hours!
this is the profile:
Fri Apr 11 09:14:04 2014 restats
19532732 function calls in 2105.024 seconds
Ordered by: internal time
ncalls tottime percall cumtime percall filename:lineno(function)
1 2087.606 2087.606 2105.006 2105.006 skymapsI.py:44(mymain)
18101000 12.757 0.000 12.757 0.000 {method 'write' of 'file'
objects}
715853 3.473 0.000 3.473 0.000 {method 'split' of 'str'
objects}
715854 1.162 0.000 1.162 0.000 {zip}
1 0.018 0.018 2105.024 2105.024 <string>:1(<module>)
6 0.006 0.001 0.006 0.001 {open}
5 0.002 0.000 0.002 0.000 {method 'close' of 'file'
objects}
1 0.000 0.000 0.000 0.000 function_base.py:8(linspace)
5 0.000 0.000 0.000 0.000 {numpy.core.multiarray.zeros}
1 0.000 0.000 0.000 0.000 function_base.py:93(logspace)
1 0.000 0.000 0.000 0.000 {numpy.core.multiarray.arange}
3 0.000 0.000 0.000 0.000 {range}
1 0.000 0.000 0.000 0.000 {method 'disable' of
'_lsprof.Prof
iler' objects}
I hope to have similar problems in the future to learn better how to do
with them!
but in the profile I don't see any operation regarding reading the file or
the mathematical operations...are them hidden in mymain()?
thanks
Gabriele
2014-04-10 21:38 GMT-04:00 Danny Yoo <dyoo at hashcollision.org>:
> > Comment: You are looping over your sliced eel five times. Do you
> > need to? I like eel salad a great deal, as well, but, how about:
> >
> >
> > for k in eel:
> > MYMAP1[i, j, k] = MYMAP1[i, j, k] + myinternet[oo]
> > MYMAP2[i, j, k] = MYMAP2[i, j, k] + myinternet[oo]
> > MYMAP3[i, j, k] = MYMAP3[i, j, k] + myinternet[oo]
> > MYMAP4[i, j, k] = MYMAP4[i, j, k] + myinternet[oo]
> > MYMAP5[i, j, k] = MYMAP5[i, j, k] + myinternet[oo]
> > oo = oo + 1
>
>
> Hi Gabriele,
>
> Also note that, when Martin looked at this part of the code, he
> unfortunately misinterpreted its effect; Martin's proposed rewrite
> here does not preserve the meaning of the original code. But rather
> than wag my finger at how Martin interpreted the code, I'd rather make
> the observation that this is a warning sign that the original code
> here was not easy to understand.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140411/bcaf31e9/attachment-0001.html>
More information about the Tutor
mailing list