summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorYaroslav Halchenko <debian@onerussian.com>2016-01-27 22:08:03 -0500
committerYaroslav Halchenko <debian@onerussian.com>2016-01-27 22:08:24 -0500
commit33777c64fefbd0919d3cf8f832c302205b4ede23 (patch)
treeb1ebf1bf2ad937853434e3ad85f35a55940f3cb5 /numpy/lib/npyio.py
parent2b34f4bf652189e0415d5bf48ef7aa3294302871 (diff)
downloadnumpy-33777c64fefbd0919d3cf8f832c302205b4ede23.tar.gz
ENH: for savez create temporary file alongside with the target file
Closes: gh-5336
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 640f4fa32..dd15db4b8 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -627,7 +627,11 @@ def _savez(file, args, kwds, compress, allow_pickle=True, pickle_kwargs=None):
zipf = zipfile_factory(file, mode="w", compression=compression)
# Stage arrays in a temporary file on disk, before writing to zip.
- fd, tmpfile = tempfile.mkstemp(suffix='-numpy.npy')
+
+ # Since target file might be big enough to exceed capacity of a global
+ # temporary directory, create temp file side-by-side with the target file.
+ file_path, file_name = os.path.split(file)
+ fd, tmpfile = tempfile.mkstemp(prefix=file_name, dir=file_path, suffix='-numpy.npy')
os.close(fd)
try:
for key, val in namedict.items():