does python support incremental recomputation?
class foo:
def __init__(self, val=6):
self.val = val
def a(self):
self.val +=5
def b(self):
self.val +=10
def c(self):
self.val *=10
def make(self):
self.a()
self.b()
self.c()
obj= foo()
obj.make()
Take an example of the code above, at times i want t开发者_如何学Co take note of the value of self.val as it enters a method and as it exists from a method. Secondily, assuming results of b() take 1 hr to compute, after a while i notice there was an error in c(), that needs modification, is it possible to begin execution just after b() has finished with execution, without running the whole program again? does python have support incremental recomputation?
The code is wrong, but regardless — just save the result when you exit the function. There is nothing here that should be done on a language level.
It seems like your goal is to save the object in case of system failure so the answer would be to pickle obj and store somewhere.
精彩评论