summaryrefslogtreecommitdiff
path: root/numpy/lib/io.py
diff options
context:
space:
mode:
authorRobert Kern <robert.kern@gmail.com>2008-04-17 20:16:11 +0000
committerRobert Kern <robert.kern@gmail.com>2008-04-17 20:16:11 +0000
commitddde39b22effbcd4799dc2dd4a229dcac0964205 (patch)
tree47bd9236e33bc38070c92c1c3a0fe80093820388 /numpy/lib/io.py
parent6e78d7dde1bc3f6247afde492bae4ae830e95d65 (diff)
downloadnumpy-ddde39b22effbcd4799dc2dd4a229dcac0964205.tar.gz
Don't require gzip or bz2 until the actual functionality is requested.
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r--numpy/lib/io.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/lib/io.py b/numpy/lib/io.py
index 6edf902e3..9e61ab2f8 100644
--- a/numpy/lib/io.py
+++ b/numpy/lib/io.py
@@ -8,7 +8,6 @@ __all__ = ['savetxt', 'loadtxt',
import numpy as np
import format
-import zipfile
import cStringIO
import tempfile
import os
@@ -42,6 +41,9 @@ class NpzFile(object):
with .files and the ZipFile object itself using .zip
"""
def __init__(self, fid):
+ # Import is postponed to here since zipfile depends on gzip, an optional
+ # component of the so-called standard library.
+ import zipfile
_zip = zipfile.ZipFile(fid)
self._files = _zip.namelist()
self.files = []
@@ -165,6 +167,10 @@ def savez(file, *args, **kwds):
arr_0, arr_1, etc.
"""
+ # Import is postponed to here since zipfile depends on gzip, an optional
+ # component of the so-called standard library.
+ import zipfile
+
if isinstance(file, str):
if not file.endswith('.npz'):
file = file + '.npz'