Mercurial > hg-stable
view mercurial/demandload.py @ 262:3db700146536
implement demand loading hack
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
implement demand loading hack
This attempts to speed up start-up times without pushing imports down
into local scopes.
manifest hash: f9c18897e67f7872b44f5c89bdde00edfc3628ce
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCo0kHywK+sNU5EO8RAg5HAKCxRKAz3FXDyv4wScq1ZbwTgfPa2gCfW9K+
dg5nC3Uvp4FilP8waF6liAY=
=dolF
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Sun, 05 Jun 2005 10:48:39 -0800 |
parents | |
children | f3abe0bdccdd |
line wrap: on
line source
def demandload(scope, modules): class d: def __getattr__(self, name): mod = self.__dict__["mod"] scope = self.__dict__["scope"] scope[mod] = __import__(mod, scope, scope, []) return getattr(scope[mod], name) for m in modules.split(): dl = d() dl.mod = m dl.scope = scope scope[m] = dl