diff options
author | Christoph Gohlke <cgohlke@uci.edu> | 2021-01-31 22:41:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 22:41:35 -0800 |
commit | 94662713ca707cf75120b197c7c7d0e3f2e62221 (patch) | |
tree | 0729550f2d89d2217e6df04cddbeea0e1fd4bf4e /numpy | |
parent | d5b6b41bcff0bd85e34f1f4afb6130fdec72ec7b (diff) | |
download | numpy-94662713ca707cf75120b197c7c7d0e3f2e62221.tar.gz |
ENH: defer the import of shutil
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/_datasource.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py index 7a23b1651..c790a6462 100644 --- a/numpy/lib/_datasource.py +++ b/numpy/lib/_datasource.py @@ -35,7 +35,6 @@ Example:: """ import os -import shutil import io from numpy.core.overrides import set_module @@ -257,6 +256,8 @@ class DataSource: def __del__(self): # Remove temp directories if hasattr(self, '_istmpdest') and self._istmpdest: + import shutil + shutil.rmtree(self._destpath) def _iszip(self, filename): @@ -319,8 +320,9 @@ class DataSource: Creates a copy of the file in the datasource cache. """ - # We import these here because importing urllib is slow and + # We import these here because importing them is slow and # a significant fraction of numpy's total import time. + import shutil from urllib.request import urlopen from urllib.error import URLError |