From f0b8dc42556541f0ff0f4e713587b0a573ef07a7 Mon Sep 17 00:00:00 2001 From: Miauwkeru Date: Tue, 20 Feb 2024 13:44:20 +0000 Subject: [PATCH] Move lru_cache definitions to __init__ (#20) Using the lru_cache decorators on class methods, the ones that have a reference to `self`, will also cache self. So we move it to the __init__ of the class (DIS-2913) --- dissect/fat/fat.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dissect/fat/fat.py b/dissect/fat/fat.py index b2206d8..d1a200e 100644 --- a/dissect/fat/fat.py +++ b/dissect/fat/fat.py @@ -160,7 +160,8 @@ def __init__(self, fh, fattype): self.entry_count = int(self.fh.size // (self.bits_per_entry / 8)) - @lru_cache(4096) + self.get = lru_cache(4096)(self.get) + def get(self, cluster): if cluster >= self.entry_count: raise ValueError(f"Cluster exceeds FAT entry count: {cluster} >= {self.entry_count}")