From 98f41861f91605899c60f0b83ab439125e78022b Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Mon, 25 Sep 2017 11:19:55 -0500 Subject: [PATCH 1/2] Use WriteOncePersistentDict instead of PersistentDict. --- setup.py | 2 +- sumpy/__init__.py | 4 ++-- sumpy/tools.py | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index c21f3b92..6f21ddce 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ setup(name="sumpy", install_requires=[ "loo.py>=2017.2", - "pytools>=2013.5.6", + "pytools>=2017.5", "boxtree>=2013.1", "pytest>=2.3", "six", diff --git a/sumpy/__init__.py b/sumpy/__init__.py index c770e802..a325e3d1 100644 --- a/sumpy/__init__.py +++ b/sumpy/__init__.py @@ -28,7 +28,7 @@ from sumpy.p2e import P2EFromSingleBox, P2EFromCSR from sumpy.e2p import E2PFromSingleBox, E2PFromCSR from sumpy.e2e import E2EFromCSR, E2EFromChildren, E2EFromParent from sumpy.version import VERSION_TEXT -from pytools.persistent_dict import PersistentDict +from pytools.persistent_dict import WriteOncePersistentDict __all__ = [ "P2P", "P2PFromCSR", @@ -37,7 +37,7 @@ __all__ = [ "E2EFromCSR", "E2EFromChildren", "E2EFromParent"] -code_cache = PersistentDict("sumpy-code-cache-v6-"+VERSION_TEXT) +code_cache = WriteOncePersistentDict("sumpy-code-cache-v6-"+VERSION_TEXT) # {{{ cache control diff --git a/sumpy/tools.py b/sumpy/tools.py index 12f385f0..2fbb1883 100644 --- a/sumpy/tools.py +++ b/sumpy/tools.py @@ -393,8 +393,12 @@ class KernelCacheWrapper(object): with MinRecursionLimit(3000): knl = self.get_optimized_kernel(**kwargs) + from pytools.persistent_dict import ReadOnlyEntryError if CACHING_ENABLED: - code_cache[cache_key] = knl + try: + code_cache[cache_key] = knl + except ReadOnlyEntryError: + pass return knl -- GitLab From ddc07eeea692c3c1ee76fbaaa377e211b799e438 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Mon, 25 Sep 2017 22:03:54 -0500 Subject: [PATCH 2/2] Use store_if_not_present() --- setup.py | 2 +- sumpy/tools.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 6f21ddce..400d1b9f 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ setup(name="sumpy", install_requires=[ "loo.py>=2017.2", - "pytools>=2017.5", + "pytools>=2017.6", "boxtree>=2013.1", "pytest>=2.3", "six", diff --git a/sumpy/tools.py b/sumpy/tools.py index 2fbb1883..428fa2a1 100644 --- a/sumpy/tools.py +++ b/sumpy/tools.py @@ -393,12 +393,8 @@ class KernelCacheWrapper(object): with MinRecursionLimit(3000): knl = self.get_optimized_kernel(**kwargs) - from pytools.persistent_dict import ReadOnlyEntryError if CACHING_ENABLED: - try: - code_cache[cache_key] = knl - except ReadOnlyEntryError: - pass + code_cache.store_if_not_present(cache_key, knl) return knl -- GitLab