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@257 | 1 | class C: |
paul@257 | 2 | a = 1 |
paul@257 | 3 | b = 2 |
paul@257 | 4 | |
paul@257 | 5 | class D(C): |
paul@257 | 6 | pass |
paul@257 | 7 | |
paul@257 | 8 | def f(): |
paul@257 | 9 | C.a = 3 # only changes C.a, not D.a |
paul@257 | 10 | |
paul@257 | 11 | print C.a # 1 |
paul@257 | 12 | print D.a # 1 |
paul@257 | 13 | print C.b # 2 |
paul@257 | 14 | print D.b # 2 |
paul@257 | 15 | |
paul@257 | 16 | f() |
paul@257 | 17 | |
paul@257 | 18 | print C.a # 3 |
paul@257 | 19 | print D.a # 1 |