I need to write a data structure stored as namedtuple
to file and read it back as a namedtuple
in python.
Solutions here suggest using Json.load
/loads
or pickle
which write the variable as json key-value pair in the form of strings. However, all my field accesses/dereferences are of the form struct.key
(rather than struct["key"]
which is the way to access json values), and it is unfeasible to correct this in the whole code.
I want to store this to a file because the struct is huge and takes a lot of time to generate.