Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 214e568

Browse filesBrowse files
authored
gh-103875: Use ascii and latin1 singletons in deepfreeze (#103876)
1 parent 438b811 commit 214e568
Copy full SHA for 214e568

File tree

1 file changed

+6
-0
lines changed
Filter options

1 file changed

+6
-0
lines changed

‎Tools/build/deepfreeze.py

Copy file name to clipboardExpand all lines: Tools/build/deepfreeze.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ def generate_unicode(self, name: str, s: str) -> str:
175175
return f"&_Py_STR({strings[s]})"
176176
if s in identifiers:
177177
return f"&_Py_ID({s})"
178+
if len(s) == 1:
179+
c = ord(s)
180+
if c < 128:
181+
return f"(PyObject *)&_Py_SINGLETON(strings).ascii[{c}]"
182+
elif c < 256:
183+
return f"(PyObject *)&_Py_SINGLETON(strings).latin1[{c - 128}]"
178184
if re.match(r'\A[A-Za-z0-9_]+\Z', s):
179185
name = f"const_str_{s}"
180186
kind, ascii = analyze_character_width(s)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.