Disable the star import cache.

This commit is contained in:
Dave Halter
2015-04-26 00:02:47 +02:00
parent 06d134a7c1
commit 0203461980
4 changed files with 21 additions and 6 deletions

View File

@@ -717,7 +717,10 @@ class ModuleWrapper(use_metaclass(CachedMetaClass, pr.Module, Wrapper)):
yield dict((str(n), [GlobalName(n)]) for n in self.base.global_names)
yield self._sub_modules_dict()
@cache_star_import
# I'm not sure if the star import cache is really that effective anymore
# with all the other really fast import caches. Recheck. Also we would need
# to push the star imports into Evaluator.modules, if we reenable this.
#@cache_star_import
@memoize_default([])
def star_imports(self):
modules = []

View File

@@ -42,15 +42,17 @@ def main(mods):
for mod in mods:
elapsed, used = profile_preload(mod)
if used > 0:
print('%8.1f | %8d | %s' % (elapsed, used, mod))
print('%8.2f | %8d | %s' % (elapsed, used, mod))
print('------------------------------')
elapsed = time.time() - t0
used = used_memory() - baseline
print('%8.1f | %8d | %s' % (elapsed, used, 'Total'))
print('%8.2f | %8d | %s' % (elapsed, used, 'Total'))
if __name__ == '__main__':
if sys.argv[1:]:
mods = sys.argv[1:]
else:
mods = ['re', 'numpy', 'scipy', 'scipy.sparse', 'scipy.stats',
'wx', 'decimal', 'PyQt4.QtGui', 'PySide.QtGui', 'Tkinter']
mods += sys.argv[1:]
main(mods)

View File

@@ -2,4 +2,6 @@ a = ''
from . import invisible_pkg
the_pkg = invisible_pkg
invisible_pkg = 1

View File

@@ -121,6 +121,14 @@ def test_import_priorities():
from import_tree import the_pkg, invisible_pkg
#? int()
invisible_pkg
# In real Python, this would be the module, but it's not, because Jedi
# doesn't care about most stateful issues such as __dict__, which it would
# need to, to do this in a correct way.
#? int()
the_pkg
# Importing foo is still possible, even though inivisible_pkg got changed.
#? float()
from import_tree.invisible_pkg import foo
# -----------------