From f02acdfd4685697bae59f1bff43b815df6520222 Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 6 Nov 2016 14:56:08 +0900 Subject: [PATCH] A couple more tweaks. --- PERFORMANCE-NOTES | 3 +++ server/block_processor.py | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/PERFORMANCE-NOTES b/PERFORMANCE-NOTES index c65f4e6..629cc96 100644 --- a/PERFORMANCE-NOTES +++ b/PERFORMANCE-NOTES @@ -5,6 +5,9 @@ account in the code. or lists with tuple(), list(). Of those list is 10% faster than tuple. +- however when not initializing from a generator, a fixed-length tuple + is at least 80% faster than a list. + - an implicit default argument is ~5% faster than passing the default explicitly diff --git a/server/block_processor.py b/server/block_processor.py index 8177da2..6116924 100644 --- a/server/block_processor.py +++ b/server/block_processor.py @@ -211,8 +211,8 @@ class MemPool(LoggedClass): return (script_hash168(txout.pk_script), txout.value) for hex_hash, tx in new_txs.items(): - txout_pairs = tuple(txout_pair(txout) for txout in tx.outputs) - self.txs[hex_hash] = [None, txout_pairs, None] + txout_pairs = [txout_pair(txout) for txout in tx.outputs] + self.txs[hex_hash] = (None, txout_pairs, None) def txin_info(txin): hex_hash = hash_to_str(txin.prev_hash) @@ -239,7 +239,7 @@ class MemPool(LoggedClass): # If we were missing a UTXO for some reason drop this tx del self.txs[hex_hash] continue - self.txs[hex_hash] = [txin_pairs, txout_pairs, any(unconfs)] + self.txs[hex_hash] = (txin_pairs, txout_pairs, any(unconfs)) # Update touched and self.hash168s for the new tx for hash168, value in txin_pairs: