From a2b004f88b0813bc853af1566842a3f4b94d0e6f Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 3 Jun 2017 13:57:44 -0400 Subject: [PATCH 1/3] Minor style cleanup --- test/test_persistent_dict.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_persistent_dict.py b/test/test_persistent_dict.py index c1f7ec7..3da5748 100644 --- a/test/test_persistent_dict.py +++ b/test/test_persistent_dict.py @@ -1,5 +1,4 @@ -from __future__ import division, with_statement -from __future__ import absolute_import +from __future__ import division, with_statement, absolute_import import pytest # noqa import sys # noqa -- GitLab From 2a8708d4035d0693e9db3a9deb136e4658450172 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 3 Jun 2017 13:59:00 -0400 Subject: [PATCH 2/3] Persistent hashes: Use nested hashes, which allows saving already-computed sub-hashes --- pytools/persistent_dict.py | 46 +++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/pytools/persistent_dict.py b/pytools/persistent_dict.py index 9bc9438..0a9fe6c 100644 --- a/pytools/persistent_dict.py +++ b/pytools/persistent_dict.py @@ -170,24 +170,44 @@ class ItemDirManager(CleanupBase): class KeyBuilder(object): def rec(self, key_hash, key): - try: - method = key.update_persistent_hash - except AttributeError: - pass - else: - method(key_hash, self) - return + digest = None try: - method = getattr(self, "update_for_"+type(key).__name__) + digest = key._pytools_persistent_hash_digest except AttributeError: pass - else: - method(key_hash, key) - return - raise TypeError("unsupported type for persistent hash keying: %s" - % type(key)) + if digest is None: + try: + method = key.update_persistent_hash + except AttributeError: + pass + else: + inner_key_hash = new_hash() + method(inner_key_hash, self) + digest = inner_key_hash.digest() + + if digest is None: + try: + method = getattr(self, "update_for_"+type(key).__name__) + except AttributeError: + pass + else: + inner_key_hash = new_hash() + method(inner_key_hash, key) + digest = inner_key_hash.digest() + + if digest is None: + raise TypeError("unsupported type for persistent hash keying: %s" + % type(key)) + + if not isinstance(key, type): + try: + key._pytools_persistent_hash_digest = digest + except Exception: + pass + + key_hash.update(digest) def __call__(self, key): key_hash = new_hash() -- GitLab From 85ba9453905134161fd3f72240e9aa0472f35eec Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 3 Jun 2017 14:02:33 -0400 Subject: [PATCH 3/3] Preinstall numpy for CI --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 028b535..7c07058 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,7 @@ Python 2.7: script: - py_version=2.7 + - export EXTRA_INSTALL="numpy" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" tags: @@ -11,6 +12,7 @@ Python 2.7: Python 3.5: script: - py_version=3.5 + - export EXTRA_INSTALL="numpy" - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-and-test-py-project.sh - ". ./build-and-test-py-project.sh" tags: -- GitLab