Commit c8a0d2f3 authored by Christian Heimes's avatar Christian Heimes

Intern static string

Use float constructors instead of magic code for float constants
parent 8e499739
...@@ -14,17 +14,7 @@ __all__ = ['JSONDecoder'] ...@@ -14,17 +14,7 @@ __all__ = ['JSONDecoder']
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
NaN, PosInf, NegInf = float('nan'), float('inf'), float('-inf')
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()
def linecol(doc, pos): def linecol(doc, pos):
......
...@@ -215,7 +215,7 @@ join_list_unicode(PyObject *lst) ...@@ -215,7 +215,7 @@ join_list_unicode(PyObject *lst)
ustr = PyUnicode_FromUnicode(&c, 0); ustr = PyUnicode_FromUnicode(&c, 0);
} }
if (joinstr == NULL) { if (joinstr == NULL) {
joinstr = PyString_FromString("join"); joinstr = PyString_InternFromString("join");
} }
if (joinstr == NULL || ustr == NULL) { if (joinstr == NULL || ustr == NULL) {
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment