diff Lib/json/decoder.py @ 46691:b0fb55ece89f legacy-trunk

Intern static string Use float constructors instead of magic code for float constants
author Christian Heimes <christian@cheimes.de>
date Tue, 06 May 2008 16:18:41 +0000
parents 4ded35754cb7
children d95e5add3ca4
line wrap: on
line diff
--- a/Lib/json/decoder.py	Tue May 06 07:05:18 2008 +0000
+++ b/Lib/json/decoder.py	Tue May 06 16:18:41 2008 +0000
@@ -14,17 +14,7 @@
 
 FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
 
-
-def _floatconstants():
-    import struct
-    import sys
-    _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
-    if sys.byteorder != 'big':
-        _BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
-    nan, inf = struct.unpack('dd', _BYTES)
-    return nan, inf, -inf
-
-NaN, PosInf, NegInf = _floatconstants()
+NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf')
 
 
 def linecol(doc, pos):