Fwd: [unladen-swallow] About startup time

Benoit Boissinot bboissin at gmail.com
Wed Apr 15 16:01:48 UTC 2009


Hi Matt,

What do you think about that ?

regards,

Benoit


---------- Forwarded message ----------
From: Thomas Wouters <twouters at google.com>
Date: Wed, Apr 15, 2009 at 5:09 PM
Subject: Re: [unladen-swallow] About startup time
To: bboissin at gmail.com
Cc: Unladen Swallow <unladen-swallow at googlegroups.com>




On Wed, Apr 15, 2009 at 15:16, bboissin <bboissin at gmail.com> wrote:
>
>
> I just noticed the following in the wiki:
>
> > Start-up time is currently dominated by imports, especially for large applications like Bazaar. Python
> > offers a lot of flexibility by deferring imports to runtime and providing a lot of hooks for configuring
> > exactly how imports will work and where modules can be imported from. The price for that
> > flexibility is slower imports.
>
> FYI, mercurial "solved" this with the demandimport module:
> http://bitbucket.org/mirror/mercurial/src/tip/mercurial/demandimport.py
>
> It lazily loads module only when they are used. This gave us some very
> nice speedups in the startup time (typically hg version).

Out of curiosity, is there a reason you don't just do
'sys.modules[head] = mod', replacing the lazy module wrapper in the
import cache? It won't affect previous imports, but any code that
imports afterwards would just get the real module object.

--
Thomas Wouters <twouters at google.com>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!



More information about the Mercurial-devel mailing list