summaryrefslogtreecommitdiff
path: root/numpy/fft
diff options
context:
space:
mode:
authorAlex Stewart <foogod@gmail.com>2014-05-02 10:07:01 -0700
committerAlex Stewart <foogod@gmail.com>2014-05-02 10:07:01 -0700
commite24486e15f9f71f63bdbc4309bcaf40e70ce7e31 (patch)
treefe35954a03f18af04aa6d1d767856e9bee46d0bc /numpy/fft
parenta0cf18394d5ce33514fdc37093bd2f65ad4b0dde (diff)
downloadpython-numpy-e24486e15f9f71f63bdbc4309bcaf40e70ce7e31.tar.gz
python-numpy-e24486e15f9f71f63bdbc4309bcaf40e70ce7e31.tar.bz2
python-numpy-e24486e15f9f71f63bdbc4309bcaf40e70ce7e31.zip
Fix for #4655: Make fftpack._raw_fft threadsafe
Diffstat (limited to 'numpy/fft')
-rw-r--r--numpy/fft/fftpack.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/numpy/fft/fftpack.py b/numpy/fft/fftpack.py
index 873249a23..7ee0e4bea 100644
--- a/numpy/fft/fftpack.py
+++ b/numpy/fft/fftpack.py
@@ -53,10 +53,9 @@ def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti,
raise ValueError("Invalid number of FFT data points (%d) specified." % n)
try:
- wsave = fft_cache[n]
- except(KeyError):
+ wsave = fft_cache.setdefault(n, []).pop()
+ except (IndexError):
wsave = init_function(n)
- fft_cache[n] = wsave
if a.shape[axis] != n:
s = list(a.shape)
@@ -77,6 +76,7 @@ def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti,
r = work_function(a, wsave)
if axis != -1:
r = swapaxes(r, axis, -1)
+ fft_cache[n].append(wsave)
return r