tstorage: speed up write() by using faster compression setting - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit d86138a1a5a144b5adc32ef8bd1ff7afd860927d DIR parent 67ae678137fe3bc8b31ce5f925f7ae40962e6132 HTML Author: SomberNight <somber.night@protonmail.com> Date: Wed, 6 Jan 2021 21:27:10 +0100 storage: speed up write() by using faster compression setting Re total runtime of WalletDB.write() and file size on disk, for a large encrypted wallet, compare: before (zlib level=6): file size 16_670 KB JsonDB.dump 0.5099 sec zlib.compress 1.3280 sec ECPubkey.encrypt_message 0.1720 sec after change (zlib level=1): file size 17_527 KB JsonDB.dump 0.5344 sec zlib.compress 0.5320 sec ECPubkey.encrypt_message 0.1837 sec Diffstat: M electrum/storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- DIR diff --git a/electrum/storage.py b/electrum/storage.py t@@ -176,7 +176,7 @@ class WalletStorage(Logger): s = plaintext if self.pubkey: s = bytes(s, 'utf8') - c = zlib.compress(s) + c = zlib.compress(s, level=zlib.Z_BEST_SPEED) enc_magic = self._get_encryption_magic() public_key = ecc.ECPubkey(bfh(self.pubkey)) s = public_key.encrypt_message(c, enc_magic)