[Stackless] Stackless for Palm Python port

Jeff Collins jcollins at endtech.com
Mon Oct 9 18:15:58 CEST 2000

On Mon, 9 Oct 2000, Christian Tismer wrote:

> Jeff Collins wrote:
> ...
> > 1)  What is the overhead imposed by the new/modified objects?
> Frames got a little larger (5 slots or so), and there are
> continuation objects which are very tiny objects (3 slots).
> > 2)  The current uthread.py module is quite large (approx 1500 LOC) and
> > will consume a large chunk of dynamic heap on import alone.  I read that
> > there are plans to convert this to C.  Will this happen any time soon?
> If you have a closer look to uthread9.py, you will realize that
> about two third or more of it consist of docstrings, comments and
> test code. So let's account for at most 500 real lines of
> python code.
> The source code is 47 kb, the generated .pyc file is 63 kb.
> After compiling with -OO it goes down to 44 kb.
> Manually removing the test code shrinks it again to 33 kb.

That's an excellent way to demonstrate the actual size.  As small as it
seems, however, this code will add at least 33kb to the Palm heap - see
the comment below.

> Writing the same stuff with all the features in C will most
> probably not generate a smaller footprint. And it should be
> noted that uthread9 has very many features, where one most
> probably can leave out a lot when space is a concern.

Without getting into too many particulars, the real issue isn't so much
code size, but where it is stored on the device.  Compiled code is run
directly from data manager RAM (limited by the amount of RAM on the
device) and only its dynamic data (and data whose addresses are determined
at run time) is stored on the heap.  Python .pyo files are currently
reconstituted entirely on the dynamic heap (current limit of 256K on a
4MB+ device running PalmOS3.5) - code and data.  I'm working on a couple
of ways to reduce the impact, but haven't implemented anything yet.  For
instance, the actual bytecode strings shouldn't be stored on the heap, but
instead read directly from the data manager where the .pyo file is store.

In any case, we have to be extremely conscientious with respect to heap
usage on the Palm.  The largest possible amount should be saved for the
Python application developer.

Jeffery D. Collins  
Sr. Software Developer
Endeavors Technology, Inc.

More information about the Stackless mailing list