Skip to content

Commit 13c71e1

Browse files
authored
pre-pep: Find possible stdlib that can be replaec to frozendict (#12)
1 parent 43c18e9 commit 13c71e1

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

Lib/json/decoder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,19 @@ def __reduce__(self):
4343
return self.__class__, (self.msg, self.doc, self.pos)
4444

4545

46-
_CONSTANTS = {
46+
_CONSTANTS = frozendict({
4747
'-Infinity': NegInf,
4848
'Infinity': PosInf,
4949
'NaN': NaN,
50-
}
50+
})
5151

5252

5353
HEXDIGITS = re.compile(r'[0-9A-Fa-f]{4}', FLAGS)
5454
STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS)
55-
BACKSLASH = {
55+
BACKSLASH = frozendict({
5656
'"': '"', '\\': '\\', '/': '/',
5757
'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t',
58-
}
58+
})
5959

6060
def _decode_uXXXX(s, pos, _m=HEXDIGITS.match):
6161
esc = _m(s, pos + 1)

Lib/json/tool.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,7 @@
2222
(?P<null>null)
2323
''', re.VERBOSE)
2424

25-
_group_to_theme_color = {
26-
"key": "definition",
27-
"string": "string",
28-
"number": "number",
29-
"boolean": "keyword",
30-
"null": "keyword",
31-
}
25+
_group_to_theme_color = frozendict(key="definition",string="string",number="number",boolean="keyword",null="keyword")
3226

3327

3428
def _colorize_json(json_str, theme):

0 commit comments

Comments
 (0)