2013-06-29 | Paul Boddie | raw annotate files changeset graph | Separated handling of getattr attribute usage from normal program unit usage, tracking only newly introduced program constants when evaluating the effects of getattr usage, and thus limiting the amount of work done identifying new program units to investigate on each occasion. | syspython-as-target |
1 #!/usr/bin/env python 2 3 class C: 4 def __init__(self): 5 self.visitor = self 6 7 def default(self, node): 8 return 123 9 10 def dispatch(self, node): 11 try: 12 return node.visit(self.visitor) 13 except AttributeError: 14 return self.visitor.default(node) 15 16 class N: 17 def visit(self, visitor): 18 return 456 19 20 c = C() 21 n = N() 22 result_456 = c.dispatch(n) 23 24 # vim: tabstop=4 expandtab shiftwidth=4