[python-dtcwt] 08/497: cache coefficients on first load
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:05:42 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.
commit 95f985eceeb94d5583540319234e914b25113cf0
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Tue Aug 6 16:54:24 2013 +0100
cache coefficients on first load
---
dtcwt/coeffs.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/dtcwt/coeffs.py b/dtcwt/coeffs.py
index 66697a7..f5b9062 100644
--- a/dtcwt/coeffs.py
+++ b/dtcwt/coeffs.py
@@ -3,9 +3,17 @@ from scipy.io import loadmat
DATADIR = os.path.join(os.path.dirname(__file__), 'data')
+COEFF_CACHE = {}
+
def _load_from_file(basename, varnames):
filename = os.path.join(DATADIR, basename + '.mat')
- mat = loadmat(filename)
+
+ try:
+ mat = COEFF_CACHE[filename]
+ except KeyError:
+ mat = loadmat(filename)
+ COEFF_CACHE[filename] = mat
+
try:
return tuple(mat[k] for k in varnames)
except KeyError:
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git
More information about the debian-science-commits
mailing list