[devctl] Optimize cleanup_sys_modules a bit 3.24
authorFlorent Cayré <florent.cayre@gmail.com>
Wed, 09 Nov 2016 23:00:00 +0100
branch3.24
changeset 11818 fdc0a8260fd2
parent 11817 48f6ebd33cb9
child 11819 a85b7a898e13
[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.
cubicweb/devtools/devctl.py
--- 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