summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-05-06 16:18:41 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-05-06 16:18:41 (GMT)
commitc8a0d2f368401adefcf39c672c74e2cfee1c32b0 (patch)
tree1fb89928ace7330e0bb14ea00fcdbe6962f63636
parent8e4997390ccb92f889ac709c9a45e589472bdee2 (diff)
downloadcpython-c8a0d2f368401adefcf39c672c74e2cfee1c32b0.zip
cpython-c8a0d2f368401adefcf39c672c74e2cfee1c32b0.tar.gz
cpython-c8a0d2f368401adefcf39c672c74e2cfee1c32b0.tar.bz2
Intern static string
Use float constructors instead of magic code for float constants
-rw-r--r--Lib/json/decoder.py12
-rw-r--r--Modules/_json.c2
2 files changed, 2 insertions, 12 deletions
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index acaee25..e80b935 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -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):
diff --git a/Modules/_json.c b/Modules/_json.c
index deee1e3..ea6d66f 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -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;