From f9271098bf1dc7ec10d9656e741dd326600207d2 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 28 Dec 2021 13:30:39 -0800 Subject: [PATCH] upload-release: Avoid appending to bytes in a loop. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Appending to bytes in a loop leads to a quadratic slowdown since Python doesn’t optimize this for bytes like it does for str. Signed-off-by: Anders Kaseorg --- tools/upload-release | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/upload-release b/tools/upload-release index 87adcc5322..30fd910250 100755 --- a/tools/upload-release +++ b/tools/upload-release @@ -96,14 +96,14 @@ if ordered_filenames[1] == new_basename: file_hashes["zulip-server-latest.tar.gz"] = file_hashes[new_basename] print("Updating SHA256SUMS.txt..") -contents = b"" +contents = "" for ordered_filename in ordered_filenames: # natsorted type annotation is insufficiently generic assert isinstance(ordered_filename, str) - contents += f"{file_hashes[ordered_filename]} {ordered_filename}\n".encode() + contents += f"{file_hashes[ordered_filename]} {ordered_filename}\n" bucket.put_object( ACL="public-read", - Body=contents, + Body=contents.encode(), ContentType="text/plain", Key="server/SHA256SUMS.txt", )