Commits

Kirill Simonov  committed fbce026

Eliminated some reference cycles.

  • Participants
  • Parent commits a3d0f2e

Comments (0)

Files changed (2)

File src/htsql/tr/flow.py

 
     def __init__(self, domain, units, binding, equality_vector=None):
         assert isinstance(domain, Domain)
-        assert isinstance(units, listof(Unit))
+        assert isinstance(units, maybe(listof(Unit)))
         super(Code, self).__init__(binding, equality_vector)
         self.domain = domain
-        self.units = units
+        # Do not assign when implemented as a property.
+        if units is not None:
+            self.units = units
 
 
 class LiteralCode(Code):
         assert isinstance(flow, Flow)
         super(Unit, self).__init__(
                     domain=domain,
-                    units=[self],
+                    units=None,
                     binding=binding,
                     equality_vector=equality_vector)
         self.flow = flow
 
+    @property
+    def units(self):
+        # Implemented as a property to avoid creating a cycle.
+        return [self]
+
     def singular(self, flow):
         """
         Verifies if the unit is singular (well-defined) on the given flow.

File src/htsql/util.py

     for element in elements:
         dfs(element)
 
+    # Break the cycle created by recursive nested function.
+    dfs = None
+
     return ordered