Python's standard way of saving class instances and reloading them is pickle mechanism. A limitation of pickle is that it does not save the code or data of a class with instance of the class being serialized.
The two module pickle and cPickle have the same functionalities, but cPickle, coded in C, is much faster
import cPickle
f = file('obj.save', 'wb')
cPickle.dump(my_obj, f, protocol=cPickle.HIGHEST_PROTOCOL)
f.close()
if you want your saved object to be stored efficiently, don't forget to use cPickle.HIGHEST_PROTOCOL. The resulting file can be dozens of times smaller than with the default protocol
Opening your file in binary mode('b') is required for portability(especially between Unix and Windows)