mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 00:14:35 +03:00
1b992606bb
-----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-----
16 lines
384 B
Python
16 lines
384 B
Python
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
|
|
|
|
|