Author Topic: Does Precompiled Python Load Faster?  (Read 2181 times)

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
Does Precompiled Python Load Faster?
« 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.
« Last Edit: May 06, 2007, 04:40:08 am by Meanie »
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

Antikx

  • Hero Member
  • *****
  • Posts: 1147
    • View Profile
    • http://tyrannozaurus.com
Does Precompiled Python Load Faster?
« Reply #1 on: May 06, 2007, 08:59:07 am »
thanks for letting us know.
Kanpai,
-Antikx (Twitter, Mugshot and PodNova)
C1000 - pdaXrom R198 (Celestial Environment)
tyrannozaurus.com
[img]http://www.tyrannozaurus.com/files/category_pictures/general_1.png\" border=\"0\" class=\"linked-sig-image\" /]
Zaurus news/blogs feed from Zaurus users
Free Windows, Linux, or Web RSS readers.
Featured pages at tyrannozaurus:
Sharp Petition, ScummVM, Cacko, pdaXii13, and Celestial Environment

zi99y

  • Sr. Member
  • ****
  • Posts: 282
    • View Profile
Does Precompiled Python Load Faster?
« Reply #2 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?

psycoman

  • Jr. Member
  • **
  • Posts: 75
    • View Profile
    • http://www.tuxforum.com.br
Does Precompiled Python Load Faster?
« Reply #3 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.