#5452 HIGH 8.2.0 (: Beat XP in activity startup time.

Zarro Boogs per Child bugtracker at laptop.org
Mon Jul 7 05:38:42 EDT 2008


#5452: Beat XP in activity startup time.
-------------------------+--------------------------------------------------
   Reporter:  cscott     |       Owner:  cjb                 
       Type:  defect     |      Status:  new                 
   Priority:  high       |   Milestone:  8.2.0 (was Update.2)
  Component:  distro     |     Version:                      
 Resolution:             |    Keywords:                      
Next_action:  never set  |    Verified:  0                   
  Blockedby:             |    Blocking:                      
-------------------------+--------------------------------------------------

Comment(by tomeu):

 {{{
 import time
 t0 = time.time()

 from lazyimport import lazyModule

 os = lazyModule('os')  # import os
 }}}

 At this point, 'os' quite probably has already been imported by time or
 lazyimport.

 {{{
 logging = lazyModule('logging')  # import logging
 from gettext import gettext as _

 gtk = lazyModule('gtk')  # import gtk
 dbus = lazyModule('dbus')  # import dbus

 from sugar.activity import activity
 }}}

 This last import imported gtk and dbus.

 {{{
 from sugar import env
 from sugar.graphics.toolbutton import ToolButton
 from sugar.graphics.palette import Palette
 import ConfigParser
 import os.path

 vte = lazyModule('vte')  # import vte
 pango = lazyModule('pango')  # import pango
 }}}

 pango had already been imported above by gtk, etc.

 And vte is needed to display the activity, so it will be imported anyway
 before we can show anything to the user. Same for gettext.

 {{{
 t1 = time.time()
 logging.debug("terminal.py: imports took %s secs" % (t1 - t0))
 }}}

 So I would be surprised if using lazy imports in this way would bring any
 improvements, I would just expect a small amount of overhead.

 If lazy imports are to be useful, it should be applied to all modules,
 without having to change code. We should move the module initialization
 from import time to first-use time.

 Perhaps we should patch python? I think that for python 3k there will be
 hooks that will allow to do this kind of things without patching.

-- 
Ticket URL: <http://dev.laptop.org/ticket/5452#comment:8>
One Laptop Per Child <http://laptop.org/>
OLPC bug tracking system


More information about the Bugs mailing list