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

Alexandre Courbot alexandrecourbot at linuxgames.com
Tue Jul 23 15:48:29 EDT 2002


> > > But that had an obscure endcase bug too, and it get replaced in
> > > 2.2 by a new float method that doesn't make unwarranted
> > > assumptions about the relative sizes of C longs and C doubles, and
> > > usually gets out quickly -- provided float arithmetic isn't pig
> > > slow.
> > 
> > Ouch!!  That doesn't sound so good for the Zaurus.
> 
> Yeah, I wonder if it's worth to profile the stuff! :)
> 
> Guys, I'll first test it with Python 2.1.3. Adonthell (the game I'm
> porting) works with any Python >= 1.5.2, so if the problem can be
> solved in the short-term by regressing to 2.1, that'll be fine for
> now. If the differences are significant, then maybe we could consider
> to add another interger-only checking method that would suit in the
> case of Arm processors. I'll try to give you news about it tomorrow.

Okay, I have cross-compiled Python 2.1.3, re-compiled Adonthell and
linked it against it, and... it's as slow as with Python 2.2. So it
looks like the overflow check isn't to blame here. I'll do some
profiling as soon as I have the time and send the results here.

My surprise is big, as Python's purpose is only to control some elements
of the game. That is, it makes calls to *our* functions written in C++.
So on a classic PC, 99% of the CPU time is spent in our functions. On
the Zaurus however, it rather looks like 90% of the time is spent into
Python, as the time runs at least 10 times slower when I enable the
Python schedules. And no matter whether Python is used or not, all our
"hot" functions are called.

Note however that the interpreter is called very often to run very short
scripts. We call PyObject_CallObject something like 70 times per second,
for each schedule (and there is something like 10 of them). Maybe there
is some context-switching or something like that and that it eats a lot
of CPU on the Zaurus? But in this case I wouldn't understand why it
isn't the case on my PC... Any idea here?

Well, I'll try to come with profiling results ASAP.

Alex.
-- 
http://www.gnurou.org




More information about the Python-list mailing list