mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-46429: tweak deepfreeze output (#32107)
This commit is contained in:
parent
c12ba6b2ff
commit
785cc67705
1 changed files with 6 additions and 0 deletions
|
@ -170,6 +170,8 @@ class Printer:
|
|||
def generate_unicode(self, name: str, s: str) -> str:
|
||||
if s in identifiers:
|
||||
return f"&_Py_ID({s})"
|
||||
if re.match(r'\A[A-Za-z0-9_]+\Z', s):
|
||||
name = f"const_str_{s}"
|
||||
kind, ascii = analyze_character_width(s)
|
||||
if kind == PyUnicode_1BYTE_KIND:
|
||||
datatype = "uint8_t"
|
||||
|
@ -326,6 +328,10 @@ class Printer:
|
|||
def generate_int(self, name: str, i: int) -> str:
|
||||
if -5 <= i <= 256:
|
||||
return f"(PyObject *)&_PyLong_SMALL_INTS[_PY_NSMALLNEGINTS + {i}]"
|
||||
if i >= 0:
|
||||
name = f"const_int_{i}"
|
||||
else:
|
||||
name = f"const_int_negative_{abs(i)}"
|
||||
if abs(i) < 2**15:
|
||||
self._generate_int_for_bits(name, i, 2**15)
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue