summaryrefslogtreecommitdiff
path: root/numpy/lib/utils.py
diff options
context:
space:
mode:
authorRobert Kern <robert.kern@gmail.com>2008-07-03 06:15:14 +0000
committerRobert Kern <robert.kern@gmail.com>2008-07-03 06:15:14 +0000
commit102cdc22b12df8a44be644d39a277229e5324028 (patch)
tree104f86c4355fd18c9bd7d7648b120a0d0c288299 /numpy/lib/utils.py
parent590babe4646a3435f8a709d6230d05c10f085be1 (diff)
downloadnumpy-102cdc22b12df8a44be644d39a277229e5324028.tar.gz
Reduce numpy's import times by delaying a few time consuming imports to the point of actual use and global instantiations of finfo. Thanks to David Cournapeau for tracking down and fixing the import part of the problem.
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r--numpy/lib/utils.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 8a119722b..7df342e02 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -1,11 +1,9 @@
-import compiler
import os
import sys
-import inspect
import pkgutil
import types
import re
-import pydoc
+
from numpy.core.numerictypes import obj2sctype, generic
from numpy.core.multiarray import dtype as _dtype
from numpy.core import product, ndarray
@@ -327,7 +325,8 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]
"""
global _namedict, _dictlist
- import pydoc
+ # Local import to speed up numpy's import time.
+ import pydoc, inspect
if hasattr(object,'_ppimport_importer') or \
hasattr(object, '_ppimport_module'):
@@ -467,6 +466,8 @@ def info(object=None,maxwidth=76,output=sys.stdout,toplevel='numpy'):
def source(object, output=sys.stdout):
"""Write source for this object to output.
"""
+ # Local import to speed up numpy's import time.
+ import inspect
try:
print >> output, "In file: %s\n" % inspect.getsourcefile(object)
print >> output, inspect.getsource(object)
@@ -599,6 +600,8 @@ def _lookfor_generate_cache(module, import_modules, regenerate):
"""
global _lookfor_caches
+ # Local import to speed up numpy's import time.
+ import inspect
if module is None:
module = "numpy"
@@ -751,6 +754,8 @@ def safe_eval(source):
...
SyntaxError: Unknown name: dict
"""
+ # Local import to speed up numpy's import time.
+ import compiler
walker = SafeEval()
try:
ast = compiler.parse(source, "eval")