[devctl] Optimize cleanup_sys_modules a bit
by moving out of a loop a costly computation that is constant.
This at least benefits the `i18ncube` command.
Related to #15789486.
--- a/cubicweb/devtools/devctl.py Thu Nov 10 10:05:14 2016 +0100
+++ b/cubicweb/devtools/devctl.py Wed Nov 09 23:00:00 2016 +0100
@@ -102,6 +102,7 @@
def cleanup_sys_modules(config):
# cleanup sys.modules, required when we're updating multiple cubes
+ appobjects_path = config.appobjects_path()
for name, mod in list(sys.modules.items()):
if mod is None:
# duh ? logilab.common.os for instance
@@ -112,7 +113,7 @@
if mod.__file__ is None:
# odd/rare but real
continue
- for path in config.appobjects_path():
+ for path in appobjects_path:
if mod.__file__.startswith(path):
del sys.modules[name]
break