diff options
-rw-r--r-- | Misc/NEWS.d/next/Build/2022-01-22-11-06-23.bpo-46471.03snrE.rst | 1 | ||||
-rw-r--r-- | Tools/scripts/deepfreeze.py | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/Misc/NEWS.d/next/Build/2022-01-22-11-06-23.bpo-46471.03snrE.rst b/Misc/NEWS.d/next/Build/2022-01-22-11-06-23.bpo-46471.03snrE.rst new file mode 100644 index 0000000..ca8f728 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2022-01-22-11-06-23.bpo-46471.03snrE.rst @@ -0,0 +1 @@ +Use global singletons for single byte bytes objects in deepfreeze.
\ No newline at end of file diff --git a/Tools/scripts/deepfreeze.py b/Tools/scripts/deepfreeze.py index a7546a8..a1ef85e 100644 --- a/Tools/scripts/deepfreeze.py +++ b/Tools/scripts/deepfreeze.py @@ -150,6 +150,8 @@ class Printer: def generate_bytes(self, name: str, b: bytes) -> str: if b == b"": return "(PyObject *)&_Py_SINGLETON(bytes_empty)" + if len(b) == 1: + return f"(PyObject *)&_Py_SINGLETON(bytes_characters[{b[0]}])" self.write("static") with self.indent(): with self.block("struct"): |