[Tutor] design ideas?

Blake Winton bwinton@latte.ca
Mon, 12 Aug 2002 11:27:39 -0400


* Thomi Richards <thomi@thomi.imail.net.nz> [020812 06:26]:
> there are several problems with this, the first is, this
> program needs to be able to run at top speeds of 50 cycles a
> second. it will have over 65'000 things to calculate each turn,
> and the speed will obviously depend on the users computer, but
> what kind of things can i do to speed up the python program??

The best advice you'll get is "Do nothing to speed it up".
Seriously.  First, write it so that it works.  Then, if it's
actually too slow, run a profiler on it to see where it's
spending all of its time, and selectively optimize that part of
it.  If it's still too slow after all of that, you can look into
using different algorithms for various parts of it (but _only_
the parts that are too slow!).  After all of that, if it's still
too slow, you can rewrite parts of it in C.  But please, don't
even start thinking about the second step until after the first
step is completed.  I work with someone who tries to optimize
everything, as he's writing it, and it's really annoying, since
it takes him several times as long as it should to get any single
task done, and when it finally is done, we can't notice the
difference in performance anyways.  ("Great, so it takes 0.001
seconds to do this instead of 0.002.  Whoopee.  I'm glad you
spent that extra week getting it so fast.  Now can you fix this
bug?")

Later,
Blake.
-- 
 11:22am  up 7 days, 19:09,  1 user,  load average: 0.00, 0.00, 0.00