We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4064858 commit d19e6cfCopy full SHA for d19e6cf
pySDC/helpers/spectral_helper.py
@@ -6,10 +6,34 @@
6
import logging
7
8
# TODO: implement cupy for transforms
9
-# TODO: fix edge cases
10
11
12
def cache(func):
+ """
13
+ Decorator for caching return values of functions.
14
+
15
+ Example:
16
17
+ .. code-block:: python
18
19
+ num_calls = 0
20
21
+ @cache
22
+ def increment(x):
23
+ num_calls += 1
24
+ return x + 1
25
26
+ increment(0) # returns 1, num_calls = 1
27
+ increment(1) # returns 2, num_calls = 2
28
+ increment(0) # returns 1, num_calls = 2
29
30
31
+ Args:
32
+ func (function): The function you want to cache the return value of
33
34
+ Returns:
35
+ return value of func
36
37
attr_cache = f"_{func.__name__}_cache"
38
39
@wraps(func)
0 commit comments