summaryrefslogtreecommitdiffstats
path: root/Tools/build
diff options
context:
space:
mode:
authorYichen Yan <oraluben@outlook.com>2023-04-26 11:45:58 (GMT)
committerGitHub <noreply@github.com>2023-04-26 11:45:58 (GMT)
commit214e5684c274f359d4cc34381f65e9f1a9952802 (patch)
tree05664373e26e8d720aa3933fe665223f10b879b0 /Tools/build
parent438b811761da124b949265d233f9fd9a74d7dd3f (diff)
downloadcpython-214e5684c274f359d4cc34381f65e9f1a9952802.zip
cpython-214e5684c274f359d4cc34381f65e9f1a9952802.tar.gz
cpython-214e5684c274f359d4cc34381f65e9f1a9952802.tar.bz2
gh-103875: Use ascii and latin1 singletons in deepfreeze (#103876)
Diffstat (limited to 'Tools/build')
-rw-r--r--Tools/build/deepfreeze.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Tools/build/deepfreeze.py b/Tools/build/deepfreeze.py
index 5cfef5c..b084d3e 100644
--- a/Tools/build/deepfreeze.py
+++ b/Tools/build/deepfreeze.py
@@ -175,6 +175,12 @@ class Printer:
return f"&_Py_STR({strings[s]})"
if s in identifiers:
return f"&_Py_ID({s})"
+ if len(s) == 1:
+ c = ord(s)
+ if c < 128:
+ return f"(PyObject *)&_Py_SINGLETON(strings).ascii[{c}]"
+ elif c < 256:
+ return f"(PyObject *)&_Py_SINGLETON(strings).latin1[{c - 128}]"
if re.match(r'\A[A-Za-z0-9_]+\Z', s):
name = f"const_str_{s}"
kind, ascii = analyze_character_width(s)