From babdc7005ca698206707e198631e9275a5259fbc Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Sat, 22 Jan 2022 16:30:36 +0530 Subject: [PATCH 1/2] use global singletons for single byte bytes objects --- Tools/scripts/deepfreeze.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tools/scripts/deepfreeze.py b/Tools/scripts/deepfreeze.py index a7546a8c607515..a1ef85ea891a27 100644 --- a/Tools/scripts/deepfreeze.py +++ b/Tools/scripts/deepfreeze.py @@ -150,6 +150,8 @@ def field(self, obj: object, name: str) -> None: 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"): From 1d87d142d4d8d8d6048aa1112321a53114322f62 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 22 Jan 2022 11:06:24 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Misc/NEWS.d/next/Build/2022-01-22-11-06-23.bpo-46471.03snrE.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2022-01-22-11-06-23.bpo-46471.03snrE.rst 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 00000000000000..ca8f72868e69ef --- /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