Python very slow on the Sharp Zaurus - any idea why?
holger krekel
pyth at devel.trillke.net
Mon Aug 12 12:50:33 EDT 2002
Dilton McGowan II wrote:
> "Alexandre Courbot" <alexandrecourbot at linuxgames.com> wrote in message
> news:mailman.1029072258.16494.python-list at python.org...
> > 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
> >
>
> I'm new to Python so your statement is interesting.
>
> So it is a lot of work for Python to increment a counter 1050 times per
> second and this is only detectable on slower machines? Does that mean that
> Python is not scalable doing simple operations?
No, i don't think so. Nevertheless, i wouldn't write e.g. a video-codec
in python except for proof of concept.
python function calls have some overhead. But not that much.
On my 180MHZ- pentium-pro i can call the function
def f():
global a
a=a+1
like this
def perform():
for i in xrange(num_iterations):
f()
over 85000 times a second. Probably the functions (that the OP mentioned
above) were at least sometimes doing a lot more (some conditional stuff,
i guess) or the Sharp Zaurus is a lot slower than i thought.
Anyway, i think implementing some stuff in C/C++ makes sense especially
if you are working with embedded devices where speed and space tend to
be more valuable.
holger
More information about the Python-list
mailing list