class A(object):
def __init__(self):
self.db = create_db_object()
def change_Db_a(self):
self.db.change_something()
self.db.save()
def change_db_b(self):
self.db.change_anotherthing()
self.db.save()
I am getting object from database, I changing it in multiple function and saving it back. which is slow because it hits database on every function call. is there anything like deconstructor where I can save the database object so that I don't have to save it for every function call and not waste time.