2018-07-03 | Paul Boddie | file changeset files shortlog | Take advantage of context testing when acquiring functions for invocation. Since a context whose nature has been determined will have been tested, either as a consequence of deduction or at run-time, use of __get_function (which tests the context again) is unnecessary. |
paul@588 | 1 | class C: |
paul@588 | 2 | def __init__(self, x): |
paul@588 | 3 | self.x = x |
paul@588 | 4 | |
paul@588 | 5 | def value(self): |
paul@588 | 6 | return self.x |
paul@588 | 7 | |
paul@588 | 8 | def length(self): |
paul@588 | 9 | return self.double(self.value()) |
paul@588 | 10 | |
paul@588 | 11 | def double(self, x): |
paul@588 | 12 | return x * 2 |
paul@588 | 13 | |
paul@588 | 14 | c = C(3) |
paul@588 | 15 | print c.length() # 6 |