handling large pickle files code example
Example 1: create pickle file python
import pickle
file_name='my_file.pkl'
f = open(file_name,'wb')
pickle.dump(my_data,f)
f.close()
Example 2: write data to using pickle
import pickle
example_dict = {1:"6",2:"2",3:"f"}
pickle_out = open("dict.pickle","wb")
pickle.dump(example_dict, pickle_out)
pickle_out.close()
Example 3: handling large pickle files pickletools
import picklefilepath = "random_forest.pkl"with open(filepath, 'wb') as f: p = pickle.Pickler(f) p.fast = True p.dump(clf)with open(filepath, 'rb') as f: p = pickle.Unpickler(f) clf = p.load()