summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/getlimits.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/numpy/core/getlimits.py b/numpy/core/getlimits.py
index f73c21f67..fcb73e8ba 100644
--- a/numpy/core/getlimits.py
+++ b/numpy/core/getlimits.py
@@ -262,11 +262,15 @@ def _get_machar(ftype):
raise ValueError(repr(ftype))
# Detect known / suspected types
key = ftype('-0.1').newbyteorder('<').tobytes()
- ma_like = _KNOWN_TYPES.get(key)
- # Could be 80 bit == 10 byte extended precision, where last bytes can be
- # random garbage. Try comparing first 10 bytes to pattern.
- if ma_like is None and ftype == ntypes.longdouble:
+ ma_like = None
+ if ftype == ntypes.longdouble:
+ # Could be 80 bit == 10 byte extended precision, where last bytes can
+ # be random garbage.
+ # Comparing first 10 bytes to pattern first to avoid branching on the
+ # random garbage.
ma_like = _KNOWN_TYPES.get(key[:10])
+ if ma_like is None:
+ ma_like = _KNOWN_TYPES.get(key)
if ma_like is not None:
return ma_like
# Fall back to parameter discovery