Skip to content

Commit 69bc68c

Browse files
NewSoupVisflavelle
authored andcommitted
Remove all functools lru cache (ArchipelagoMW#3446)
1 parent 0c2d434 commit 69bc68c

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

worlds/witness/data/static_logic.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from collections import defaultdict
2-
from functools import lru_cache
32
from typing import Dict, List, Set, Tuple
43

4+
from Utils import cache_argsless
5+
56
from .item_definition_classes import (
67
CATEGORY_NAME_MAPPINGS,
78
DoorItemDefinition,
@@ -260,17 +261,17 @@ def get_parent_progressive_item(item_name: str) -> str:
260261
return _progressive_lookup.get(item_name, item_name)
261262

262263

263-
@lru_cache
264+
@cache_argsless
264265
def get_vanilla() -> StaticWitnessLogicObj:
265266
return StaticWitnessLogicObj(get_vanilla_logic())
266267

267268

268-
@lru_cache
269+
@cache_argsless
269270
def get_sigma_normal() -> StaticWitnessLogicObj:
270271
return StaticWitnessLogicObj(get_sigma_normal_logic())
271272

272273

273-
@lru_cache
274+
@cache_argsless
274275
def get_sigma_expert() -> StaticWitnessLogicObj:
275276
return StaticWitnessLogicObj(get_sigma_expert_logic())
276277

worlds/witness/data/utils.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from functools import lru_cache
21
from math import floor
32
from pkgutil import get_data
43
from random import random
@@ -103,10 +102,15 @@ def parse_lambda(lambda_string) -> WitnessRule:
103102
return lambda_set
104103

105104

106-
@lru_cache(maxsize=None)
105+
_adjustment_file_cache = dict()
106+
107+
107108
def get_adjustment_file(adjustment_file: str) -> List[str]:
108-
data = get_data(__name__, adjustment_file).decode("utf-8")
109-
return [line.strip() for line in data.split("\n")]
109+
if adjustment_file not in _adjustment_file_cache:
110+
data = get_data(__name__, adjustment_file).decode("utf-8")
111+
_adjustment_file_cache[adjustment_file] = [line.strip() for line in data.split("\n")]
112+
113+
return _adjustment_file_cache[adjustment_file]
110114

111115

112116
def get_disable_unrandomized_list() -> List[str]:

0 commit comments

Comments
 (0)