Commits

Christian Heimes  committed b0fb55e

Intern static string
Use float constructors instead of magic code for float constants

  • Participants
  • Parent commits 5ae8d54
  • Branches legacy-trunk

Comments (0)

Files changed (2)

File Lib/json/decoder.py

 
 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):

File Modules/_json.c

         ustr = PyUnicode_FromUnicode(&c, 0);
     }
     if (joinstr == NULL) {
-        joinstr = PyString_FromString("join");
+        joinstr = PyString_InternFromString("join");
     }
     if (joinstr == NULL || ustr == NULL) {
         return NULL;