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.
2 parents cf45859 + 0e17e2d commit 17ae4afCopy full SHA for 17ae4af
hexrd/utils/decorators.py
@@ -75,8 +75,15 @@ def wrapped(*args, **kwargs):
75
# Remove the left item (least recently used)
76
cache.popitem(last=False)
77
78
+ output = func(*args, **kwargs)
79
+ if isinstance(output, np.ndarray):
80
+ # Make the array readonly so that caller functions *cannot*
81
+ # modify the cached output array. Otherwise, we run into
82
+ # hard-to-track-down bugs.
83
+ output.flags.writeable = False
84
+
85
# This inserts the item on the right (most recently used)
- cache[key] = func(*args, **kwargs)
86
+ cache[key] = output
87
misses += 1
88
else:
89
# Move the item to the right (most recently used)
0 commit comments