From ede83eeb8e734c308bd614c3a479c62cc30625b3 Mon Sep 17 00:00:00 2001 From: Rhinemann Date: Sun, 25 Jun 2023 22:57:12 +0300 Subject: [PATCH] Optimised reverse method (I have proofs of speed) (I have been slightly mistaken). --- bitutilities.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bitutilities.py b/bitutilities.py index 064ed3b..ff9adbe 100644 --- a/bitutilities.py +++ b/bitutilities.py @@ -15,8 +15,7 @@ class BasicRegister: return f"Memory: {[int(value) for value in self.memory]}" def reverse(self): - for i, value in enumerate(self.memory): - self.memory[i] = not value + self.memory = deque([not value for value in self.memory]) def left_shift(self, digit_to_fill: bool = False, steps_shifted: int = 1) -> deque[bool]: self.memory.extend([digit_to_fill] * steps_shifted)