A cycle made from recursive function calls.
| 234 | |
| 235 | |
| 236 | class Cycle(Object): |
| 237 | """A cycle made from recursive function calls.""" |
| 238 | |
| 239 | def __init__(self): |
| 240 | Object.__init__(self) |
| 241 | # XXX: Do cycles need an id? |
| 242 | self.functions = set() |
| 243 | |
| 244 | def add_function(self, function): |
| 245 | assert function not in self.functions |
| 246 | self.functions.add(function) |
| 247 | # XXX: Aggregate events? |
| 248 | if function.cycle is not None: |
| 249 | for other in function.cycle.functions: |
| 250 | if function not in self.functions: |
| 251 | self.add_function(other) |
| 252 | function.cycle = self |
| 253 | |
| 254 | |
| 255 | class Profile(Object): |