diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-02-04 17:57:03 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 17:57:03 (GMT) |
commit | bf95ff91f2c1fc5a57190491f9ccdc63458b089e (patch) | |
tree | 859c08ec6a673693121873c09dbacd148e12bb65 /Lib/ctypes | |
parent | 9b4e3d94a5746af093392ed8e977b26fcc1bfd11 (diff) | |
download | cpython-bf95ff91f2c1fc5a57190491f9ccdc63458b089e.zip cpython-bf95ff91f2c1fc5a57190491f9ccdc63458b089e.tar.gz cpython-bf95ff91f2c1fc5a57190491f9ccdc63458b089e.tar.bz2 |
bpo-46608: exclude marshalled-frozen data if deep-freezing to save 300 KB space (GH-31074)
This reduces the size of the data segment by **300 KB** of the executable because if the modules are deep-frozen then the marshalled frozen data just wastes space. This was inspired by comment by @gvanrossum in https://github.com/python/cpython/pull/29118#issuecomment-958521863. Note: There is a new option `--deepfreeze-only` in `freeze_modules.py` to change this behavior, it is on be default to save disk space.
```console
# du -s ./python before
27892 ./python
# du -s ./python after
27524 ./python
```
Automerge-Triggered-By: GH:ericsnowcurrently
Diffstat (limited to 'Lib/ctypes')
-rw-r--r-- | Lib/ctypes/test/test_values.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/ctypes/test/test_values.py b/Lib/ctypes/test/test_values.py index 3e8b137..b2db426 100644 --- a/Lib/ctypes/test/test_values.py +++ b/Lib/ctypes/test/test_values.py @@ -54,6 +54,7 @@ class PythonValuesTestCase(unittest.TestCase): _fields_ = [("name", c_char_p), ("code", POINTER(c_ubyte)), ("size", c_int), + ("is_package", c_bool), ("get_code", POINTER(c_ubyte)), # Function ptr ] FrozenTable = POINTER(struct_frozen) @@ -71,13 +72,14 @@ class PythonValuesTestCase(unittest.TestCase): modname = entry.name.decode("ascii") modules.append(modname) with self.subTest(modname): - # Do a sanity check on entry.size and entry.code. - self.assertGreater(abs(entry.size), 10) - self.assertTrue([entry.code[i] for i in range(abs(entry.size))]) + if entry.size != 0: + # Do a sanity check on entry.size and entry.code. + self.assertGreater(abs(entry.size), 10) + self.assertTrue([entry.code[i] for i in range(abs(entry.size))]) # Check the module's package-ness. with import_helper.frozen_modules(): spec = importlib.util.find_spec(modname) - if entry.size < 0: + if entry.is_package: # It's a package. self.assertIsNotNone(spec.submodule_search_locations) else: |