From acb11a9f5691ae981dc430d9bd65592c32583522 Mon Sep 17 00:00:00 2001 From: harshitgupta31415 Date: Sun, 11 Oct 2026 15:37:20 +0530 Subject: [PATCH] mofile: avoid repeated string-table copies Use separate bytearray buffers for message ids and translations instead of rebuilding bytes objects for each entry. Keep the same offsets and final bytes write. --- babel/messages/mofile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/babel/messages/mofile.py b/babel/messages/mofile.py index 2413f7139..164d0b41b 100644 --- a/babel/messages/mofile.py +++ b/babel/messages/mofile.py @@ -163,7 +163,8 @@ def write_mo(fileobj: SupportsWrite[bytes], catalog: Catalog, use_fuzzy: bool = messages[1:] = [m for m in messages[1:] if m.string and (use_fuzzy or not m.fuzzy)] messages.sort() - ids = strs = b'' + ids = bytearray() + strs = bytearray() offsets = [] for message in messages: