mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
bpo-46712: Share global string identifiers in deepfreeze (GH-31261)
Where appropriate, deepfreeze.c now uses `&_Py_ID(blah)` references instead of locally defining constants. This saves some space.
This commit is contained in:
parent
ea9612a17b
commit
eb002dbe0d
3 changed files with 14 additions and 6 deletions
|
@ -15,9 +15,10 @@ import types
|
|||
from typing import Dict, FrozenSet, TextIO, Tuple
|
||||
|
||||
import umarshal
|
||||
from generate_global_objects import get_identifiers_and_strings
|
||||
|
||||
verbose = False
|
||||
|
||||
identifiers = get_identifiers_and_strings()[0]
|
||||
|
||||
def isprintable(b: bytes) -> bool:
|
||||
return all(0x20 <= c < 0x7f for c in b)
|
||||
|
@ -167,6 +168,8 @@ class Printer:
|
|||
return f"& {name}.ob_base.ob_base"
|
||||
|
||||
def generate_unicode(self, name: str, s: str) -> str:
|
||||
if s in identifiers:
|
||||
return f"&_Py_ID({s})"
|
||||
kind, ascii = analyze_character_width(s)
|
||||
if kind == PyUnicode_1BYTE_KIND:
|
||||
datatype = "uint8_t"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue