OESF Portables Forum

Model Specific Forums => Sharp Zaurus => Zaurus - pdaXrom => Topic started by: Meanie on May 06, 2007, 04:37:13 am

Title: Does Precompiled Python Load Faster?
Post by: Meanie on May 06, 2007, 04:37:13 am
well, theory is that pre compiled python code (.pyc) loads faster than uncompiled python code (.py)

so I thought, why not pre compile the pdaXrom config tools that are written in python to make them load faster?

to test this, I moved the code in the python config tools out of the main file into module files and have the main file just import those module files.

for example, for the datentime.py i moved all the code to pdaXconfig_datentime.py and rename datentime.py to datentime and stripped all the code except the __main__ section and the include to include the pdaXconfig_datentime module.

when running datentime for the first time, it compiled pdaXconfig_datentime.py into pdaXconfig_datentime.pyc
i then deleted pdaXconfg_datentime.py

now when running datentime it loads the precompiled pdaXconfig_datentime.pyc module

i also tested running the original datentime.py

unfortunately, there doesn't appear to be any significant improvement in loading time, maybe there are a few milliseconds of improvements, but that isn't important to me.

running datentime or datentime.py the first time always takes a long time to load. running it (either one of them) a second time, is much faster to load. this is because it needs to load python itself on the first load, and since python had been loaded and cached already in the second run, it loads faster.

thus, the conclusion i get is that loading python is what is causing the long load time of those admin/config tools, and pre compiling the python code does not provide any significant load time gains.

if you want to test it out yourself, i have attached a package with all the python config/admin tools precompiled.
Title: Does Precompiled Python Load Faster?
Post by: Antikx on May 06, 2007, 08:59:07 am
thanks for letting us know.
Title: Does Precompiled Python Load Faster?
Post by: zi99y on May 06, 2007, 04:51:44 pm
That's interesting I've wondered about python speed issues myself. So is there a way to preload the python interpreter into ram to avoid this slowdown, and does that mean that it loads portions of python on demand as functions are required?

I have been tempted to start learning a little python but decided that it's too slow in pdaxrom for some things.

What about using a different gui toolkit (tk/tcl, fltk) instead of gtk?
Title: Does Precompiled Python Load Faster?
Post by: psycoman on May 07, 2007, 08:07:49 am
For me the problem is the languague in arm processor, not the widget, i will do some tries with C/GTK code.