13 months ago | Paul Boddie | raw annotate files changeset graph | Permit the replacement of floating-point values in locally-referenced objects. To achieve this, a result target parameter has been introduced in callable signatures alongside the existing context parameter so that references to objects can be propagated to operations that are able to replace the value of such objects. Result target objects are currently supported only for locals and intermediate results in functions and methods, with assignments to locals or the storage of intermediate results involving the copying of any given floating-point objects instead of merely referencing them. Such distinct copies may then be used as result targets when locals or intermediate result locations are subsequently reused. Value replacement avoids the allocation of temporary objects that can quickly dominate execution time in programs repeatedly performing large numbers of floating-point calculations. | value-replacement |
1 class C: 2 def __init__(.x, .y, .z, x): # no explicit self, attributes initialised 3 pass 4 5 def c(): 6 return self.x 7 8 class D(C): 9 def d(): 10 return self.y 11 12 class E(D): 13 def c(): 14 return self.z 15 16 c = C(1, 2, 3, 4) 17 d = D(1, 2, 3, 4) 18 e = E(1, 2, 3, 4) 19 20 print c.c() # 1 21 print d.c() # 1 22 print e.c() # 3 23 print d.d() # 2 24 print e.d() # 2