[Python-checkins] r62769 - in python/trunk: Lib/json/decoder.py Modules/_json.c
christian.heimes
python-checkins at python.org
Tue May 6 18:18:42 CEST 2008
Author: christian.heimes
Date: Tue May 6 18:18:41 2008
New Revision: 62769
Log:
Intern static string
Use float constructors instead of magic code for float constants
Modified:
python/trunk/Lib/json/decoder.py
python/trunk/Modules/_json.c
Modified: python/trunk/Lib/json/decoder.py
==============================================================================
--- python/trunk/Lib/json/decoder.py (original)
+++ python/trunk/Lib/json/decoder.py Tue May 6 18:18:41 2008
@@ -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):
Modified: python/trunk/Modules/_json.c
==============================================================================
--- python/trunk/Modules/_json.c (original)
+++ python/trunk/Modules/_json.c Tue May 6 18:18:41 2008
@@ -215,7 +215,7 @@
ustr = PyUnicode_FromUnicode(&c, 0);
}
if (joinstr == NULL) {
- joinstr = PyString_FromString("join");
+ joinstr = PyString_InternFromString("join");
}
if (joinstr == NULL || ustr == NULL) {
return NULL;
More information about the Python-checkins
mailing list