summaryrefslogtreecommitdiffstats
path: root/Tools/scripts/deepfreeze.py
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-02-25 18:05:24 (GMT)
committerGitHub <noreply@github.com>2022-02-25 18:05:24 (GMT)
commiteb002dbe0da9622245a355db5f0cd5aa2fc70b40 (patch)
tree6d46f4c375a31a6b66e1c806f492972fc571e9c2 /Tools/scripts/deepfreeze.py
parentea9612a17bc60d44e0058f525d3c02a91c439cef (diff)
downloadcpython-eb002dbe0da9622245a355db5f0cd5aa2fc70b40.zip
cpython-eb002dbe0da9622245a355db5f0cd5aa2fc70b40.tar.gz
cpython-eb002dbe0da9622245a355db5f0cd5aa2fc70b40.tar.bz2
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.
Diffstat (limited to 'Tools/scripts/deepfreeze.py')
-rw-r--r--Tools/scripts/deepfreeze.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Tools/scripts/deepfreeze.py b/Tools/scripts/deepfreeze.py
index b62be37..8ea232f 100644
--- a/Tools/scripts/deepfreeze.py
+++ b/Tools/scripts/deepfreeze.py
@@ -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"