summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-10-16 17:07:18 -0700
committerGitHub <noreply@github.com>2019-10-16 17:07:18 -0700
commite65b7f8ebfe62feb95205e5fc4da559e4eabe88d (patch)
tree1518d6a313f5c1549c7799eb9f13d83b9c5e7b8a /lib
parentffe87ed49f928035bc0bafa5f2b834a38e694b51 (diff)
downloadspack-e65b7f8ebfe62feb95205e5fc4da559e4eabe88d.tar.gz
spack-e65b7f8ebfe62feb95205e5fc4da559e4eabe88d.tar.bz2
spack-e65b7f8ebfe62feb95205e5fc4da559e4eabe88d.tar.xz
spack-e65b7f8ebfe62feb95205e5fc4da559e4eabe88d.zip
importing: make importlib_importer recognize .pyc cache (#13239)
Our importer was always parsing from source (which is considerably slower) because the source size recorded in the .pyc file differed from the size of the input file. Override path_stats in the prepending importer to fool it into thinking that the source size is the size *with* the prepended code.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/util/imp/importlib_importer.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/spack/spack/util/imp/importlib_importer.py b/lib/spack/spack/util/imp/importlib_importer.py
index 9eec569574..33c50cb601 100644
--- a/lib/spack/spack/util/imp/importlib_importer.py
+++ b/lib/spack/spack/util/imp/importlib_importer.py
@@ -15,6 +15,12 @@ class PrependFileLoader(SourceFileLoader):
super(PrependFileLoader, self).__init__(full_name, path)
self.prepend = prepend
+ def path_stats(self, path):
+ stats = super(PrependFileLoader, self).path_stats(path)
+ if self.prepend:
+ stats["size"] += len(self.prepend) + 1
+ return stats
+
def get_data(self, path):
data = super(PrependFileLoader, self).get_data(path)
if path != self.path or self.prepend is None: