From d072d50fd965f868955421a6e8b702adcf60bbd2 Mon Sep 17 00:00:00 2001 From: ValdikSS Date: Tue, 14 Jan 2025 11:44:57 +0300 Subject: [PATCH] Replace bytes with bytearray for massive speed up Bytes type is very inefficient for append/concatenation and involves copying the entire data. This one-line fix speeds up foomatic-db compression from ~20 minutes to 10 seconds. --- pyppd/archiver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyppd/archiver.py b/pyppd/archiver.py index 1de90c0..a5e44c1 100644 --- a/pyppd/archiver.py +++ b/pyppd/archiver.py @@ -44,7 +44,7 @@ def compress(directory): returns a compressed pickle dump of it. """ - ppds = b"" + ppds = bytearray() ppds_index = {} abs_directory = os.path.abspath(directory)