2009-05-17 | Paul Boddie | raw annotate files changeset graph | Moved argument checking inside functions, changing the role of CheckFrame and introducing a separate FillDefaults instruction. Introduced a JumpWithFrameDirect instruction which is able, in conjunction with a new code_body_location attribute on Function and Class instances (for function bodies and class instantiator bodies respectively), to skip argument checking for invocations which could be checked at compile-time. Removed the invocation details from the common object structure. Improved various tests. |
1 #!/usr/bin/env python 2 3 class C: 4 def g(self): 5 return self.f # C.f with context self 6 def f(self): pass 7 8 def test(self): 9 self.f() 10 self.g() 11 12 class D: 13 f = C.f 14 def g(self): 15 return self.f # D.f with context preserved 16 17 def test(self): 18 self.f(2) 19 self.g() 20 21 class E(C): 22 def g(self): 23 return self.f # C.f with context self 24 25 def test(self): 26 self.f() 27 self.g() 28 29 C.f 30 D.f 31 E.f 32 33 c = C() 34 d = D() 35 e = E() 36 37 x = c.f # bound C.f == c.g() 38 y = d.f # unbound C.f == d.g() 39 z = e.f # bound E.f == e.g() 40 41 # vim: tabstop=4 expandtab shiftwidth=4