]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Intern static string
authorChristian Heimes <christian@cheimes.de>
Tue, 6 May 2008 16:18:41 +0000 (16:18 +0000)
committerChristian Heimes <christian@cheimes.de>
Tue, 6 May 2008 16:18:41 +0000 (16:18 +0000)
Use float constructors instead of magic code for float constants

Lib/json/decoder.py
Modules/_json.c

index acaee251f36f0ba8441321df256773e8c6298c32..e80b93541b7f331fb5234394225ccc150fddf5d3 100644 (file)
@@ -14,17 +14,7 @@ __all__ = ['JSONDecoder']
 
 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):
index deee1e3d7a9e925be6de0b6458fec5073a567955..ea6d66f60cac9e6a58c65228272a72ff69de2ff5 100644 (file)
@@ -215,7 +215,7 @@ join_list_unicode(PyObject *lst)
         ustr = PyUnicode_FromUnicode(&c, 0);
     }
     if (joinstr == NULL) {
-        joinstr = PyString_FromString("join");
+        joinstr = PyString_InternFromString("join");
     }
     if (joinstr == NULL || ustr == NULL) {
         return NULL;