[maemo-developers] python startup time
From: Martin Grimme martin.grimme at gmail.comDate: Sat Nov 10 23:04:42 EET 2007
- Previous message: python startup time
- Next message: python startup time
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
if you are importing lots of modules, you can get the startup time down by
not importing the modules at the top of a file, but at the place where you
need it in a function.
Note that modules are loaded only once, so subsequent import commands will
have no effect.
Example:
instead of this:
import os
def foo():
print os.listdir()
you can write this:
def foo():
import os
print os.listdir()
Cheers,
Martin
2007/11/9, Jesse Guardiani <jesse at guardiani.us>:
>
> Hello,
>
> Is there anything that can be done about python startup time?
> I recently wrote a very simple little pygtk + glade application that is
> less than 110 lines of code and it takes between 5 and 9 seconds to start
> up.
>
> http://www.guardiani.us/projects/tip_calc/browser/trunk/src/tip_calc/tip_calc.py
> Any way to get that startup time down?
>
>
> --
> Jesse Guardiani
> Software Developer / Sys Admin
> jesse at guardiani.us
> _______________________________________________
> maemo-developers mailing list
> maemo-developers at maemo.org
> https://lists.maemo.org/mailman/listinfo/maemo-developers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maemo.org/pipermail/maemo-developers/attachments/20071110/104ad55b/attachment.htm
- Previous message: python startup time
- Next message: python startup time
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
