summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/numerictypes.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index bdaa88cb8..f0cd8ec74 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -746,9 +746,10 @@ def sctype2char(sctype):
# Create dictionary of casting functions that wrap sequences
# indexed by type or type character
-
-
cast = _typedict()
+for key in _sctype2char_dict.keys():
+ cast[key] = lambda x, k=key: array(x, copy=False).astype(k)
+
try:
ScalarType = [_types.IntType, _types.FloatType, _types.ComplexType,
_types.LongType, _types.BooleanType,
@@ -759,11 +760,8 @@ except AttributeError:
ScalarType.extend(_sctype2char_dict.keys())
ScalarType = tuple(ScalarType)
-for key in _sctype2char_dict.keys():
- cast[key] = lambda x, k=key: array(x, copy=False).astype(k)
# Add additional strings to the sctypeDict
-
if sys.version_info[0] >= 3:
_toadd = ['int', 'float', 'complex', 'bool', 'object',
'str', 'bytes', 'object', ('a', allTypes['bytes_'])]