I have a python code which uses some singleton class. One of the usecases I need is to store the class as a pickled object. The application logic controls when to read from the pickled object and when to rebuild it (something like caching).
The problem is that the object type/name is identical to the in memory object, and due to it, even when changing it's name before saving it - I end up with having same reference.
Due to it, I can't control copying values to runtime from a pickled object (partial pickled..)
What can I do?
Example:
class A:
some_attribute = ""
A.some_attribute = "a new runtime data"
with open("pickled_object.pk", "wb") as pk:
pickle.dump(A, pk)
----
"" different startup ability ""
with open("pickled_object.pk", "rb") as pk:
A = pickle.load(pk)
I hope you got the idea, I will edit in case needed more information..