From 74b2a3f948401415bd86bcf4405c2c7077f77ac2 Mon Sep 17 00:00:00 2001 From: Maxim Tarasov Date: Sat, 11 May 2024 11:11:44 -0700 Subject: [PATCH] eliminate reference cycle in IndexVar --- Tests/utils_for_test.py | 2 +- pynars/Narsese/_py/Term.py | 4 ++-- pynars/utils/IndexVar.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/utils_for_test.py b/Tests/utils_for_test.py index ac6f722..826a49a 100644 --- a/Tests/utils_for_test.py +++ b/Tests/utils_for_test.py @@ -18,7 +18,7 @@ nars = Reasoner(100, 100) engine: GeneralEngine = nars.inference -NUM_CYCLES_MULTIPLIER = 10 +NUM_CYCLES_MULTIPLIER = 20 def process_two_premises(premise1: str, premise2: str, n_cycle: int = 0) -> List[Task]: '''''' time_before = Global.time diff --git a/pynars/Narsese/_py/Term.py b/pynars/Narsese/_py/Term.py index cc39b58..b240611 100644 --- a/pynars/Narsese/_py/Term.py +++ b/pynars/Narsese/_py/Term.py @@ -217,8 +217,8 @@ def _build_vars(self): def clone(self): - clone = deepcopy(self) - return clone + # clone = copy(self) + return self def _normalize_variables(self): '''''' diff --git a/pynars/utils/IndexVar.py b/pynars/utils/IndexVar.py index 037580c..8821e58 100644 --- a/pynars/utils/IndexVar.py +++ b/pynars/utils/IndexVar.py @@ -124,7 +124,7 @@ def __init__(self) -> None: self.positions = [] # the positions of each dependent variable self.indices = [] # the dependent variable in each position. - self.predecessor: IndexVar = None + # self.predecessor: IndexVar = None self.successors: List[IndexVar] = [] self._is_built = False @@ -165,7 +165,7 @@ def clone(self): def connect(self, successor: 'IndexVar', generate_pos=False): '''''' self.successors.append(successor) - successor.predecessor = self + # successor.predecessor = self if not generate_pos: return