Python very slow on the Sharp Zaurus - any idea why?

Alexandre Courbot alexandrecourbot at linuxgames.com
Sun Aug 11 09:35:12 EDT 2002


Okay, sorry for having been so long to reply - most of you probably
don't remember this thread, I have been unable to find it back on my
machine myself! :)

The issue was that I had great trouble running our game (which uses
Python for events and NPCs control) at a decent speed on the Zaurus, and
that disabling all Python scripting was enough to make it smooth. I
suspected some floating point stuff to be done internally by Python,
what the Z doesn't like at all (having no floating point unit, floating
point operations are done in software). I said that I would come with
some profiling.

Actually, I was totally wrong since the beginning. Running the same game
on a P200 (roughly equivalent to the Z's StrongArm) is as slow as
running it on the Zaurus. The bottleneck was very easy to find out
however:

We handle 15 characters in the game, each one having its own Python
schedule run every game cycle. There are 70 game cycles per second,
which makes at least 15 * 70 = 1050 calls to Python methods per second.
Most of the time, it is just to decrement a counter. So you can imagine
that the overhead caused by the Python calls is disproportionated
compared to what is actually performed. Recent processors were able to
support it, but older or weaker ones can't, obviously.

We have redone our schedule system, so that all the obvious stuff is
moved to C++ and it is not necessary to call Python schedules all the
time. Well, you got it - it's working flawlessly now, even on the
Zaurus. So Python is fine. Python is great! :) It was just an obvious
design problem that would have been avoided if we used more modest
machines. Sorry for all the useless brain work my initial post
triggered!

See you all,
Alex.
-- 
http://www.gnurou.org




More information about the Python-list mailing list