You don't know what's slow. This is the perfect tool for a profiler.

http://docs.python.org/lib/profile.html

     --Michael

On 10/9/07, Øyvind <[EMAIL PROTECTED]> wrote:
>
> Hello.
>
> I have written a simple application that does a number of simple
> calculations. In psudo-code it looks something like below.
>
> The program works fine. However, it seems like I need a supercomputer to
> finish the resultwithin a reasonable timeframe, as the var.txt contains a
> lot of variables that has to be computed. And, since my budget doesn't
> include a supercomputer, I need to optimize the script. I have been able
> to half the running-time by flushing the file more seldom, and a little
> more by try and fail. However, half is still a looong time. I would like
> to increase the speed even more.
>
> Does anyone have any suggestions of what I should do? Is Stackless Python
> an option? Is there some other steps I could take? Some basic steps?
>
> Thanks in advance,
> Øyvind
>
> class start:
>
>     filles = open("var.txt","r") into memory
>
>     def oppned(self):
>         return randint(0,1)
>
>     def verdier(self):
>         increase variable x and y
>
>     def verdi(self):
>         for i in filles:
>             generate random from oppned
>             simple calculation
>
>             if result 1:
>                  write result
>
>             if result 2:
>                  generate new random, calculate more
>                  write result
>
>             if result 3:
>                  write result, use new variable
>
> if __name__ == '__main__':
>     n = start()
>     for x in range(0,10000):
>         n.verdier()
>         for y in range(0,100):
>             n.verdi()
>
>         n.fil.write(result)
>         if variable x > 0.32:
>             break
>
>
>
> --
> This email has been scanned for viruses & spam by Domenebutikken -
> www.domenebutikken.no
> Denne e-posten er sjekket for virus & spam av Domenebutikken -
> www.domenebutikken.no
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



-- 
Michael Langford
Phone: 404-386-0495
Consulting: http://www.TierOneDesign.com/
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to