Skip to content

Commit 2f11bca

Browse files
committed
Added caching decorator (Parallel-in-Time#554)
* Implemented caching wrapper for spectral helper * Added test for caching decorator
1 parent 2967b6a commit 2f11bca

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

pySDC/helpers/spectral_helper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
def cache(func):
1212
"""
1313
Decorator for caching return values of functions.
14+
This is very similar to `functools.cache`, but without the memory leaks (see
15+
https://docs.astral.sh/ruff/rules/cached-instance-method/).
1416
1517
Example:
1618

pySDC/tests/test_helpers/test_spectral_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ def test_identity_matrix_ND(nx, ny, nz, variant, bx, useMPI=False, **kwargs):
749749

750750

751751
@pytest.mark.base
752-
def test_cache():
752+
def test_cache_decorator():
753753
from pySDC.helpers.spectral_helper import cache
754754
import numpy as np
755755

0 commit comments

Comments
 (0)