diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-02-25 18:05:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-25 18:05:24 (GMT) |
commit | eb002dbe0da9622245a355db5f0cd5aa2fc70b40 (patch) | |
tree | 6d46f4c375a31a6b66e1c806f492972fc571e9c2 /Tools/scripts/generate_global_objects.py | |
parent | ea9612a17bc60d44e0058f525d3c02a91c439cef (diff) | |
download | cpython-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/generate_global_objects.py')
-rw-r--r-- | Tools/scripts/generate_global_objects.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Tools/scripts/generate_global_objects.py b/Tools/scripts/generate_global_objects.py index bad7865..506aa86 100644 --- a/Tools/scripts/generate_global_objects.py +++ b/Tools/scripts/generate_global_objects.py @@ -256,13 +256,10 @@ def generate_runtime_init(identifiers, strings): printer.write(after) -####################################### -# the script - -def main() -> None: +def get_identifiers_and_strings() -> tuple[set[str], dict[str, str]]: identifiers = set(IDENTIFIERS) strings = dict(STRING_LITERALS) - for name, string, filename, lno, _ in iter_global_strings(): + for name, string, *_ in iter_global_strings(): if string is None: if name not in IGNORED: identifiers.add(name) @@ -271,6 +268,13 @@ def main() -> None: strings[name] = string elif string != strings[name]: raise ValueError(f'string mismatch for {name!r} ({string!r} != {strings[name]!r}') + return identifiers, strings + +####################################### +# the script + +def main() -> None: + identifiers, strings = get_identifiers_and_strings() generate_global_strings(identifiers, strings) generate_runtime_init(identifiers, strings) |