From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sun, 23 Jan 2022 17:45:39 +0000 (+0530) Subject: bpo-46471: Use single byte singletons (GH-30781) X-Git-Tag: v3.11.0a5~127 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca78130d7eb5265759697639e42487ec6d0a4caf;p=thirdparty%2FPython%2Fcpython.git bpo-46471: Use single byte singletons (GH-30781) --- 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 000000000000..ca8f72868e69 --- /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 a7546a8c6075..a1ef85ea891a 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"):