I have a large object in my Python3 code which, when tried to be pickled with the pickle
module throws the following error:
TypeError: cannot serialize '_io.BufferedReader' object
However, dill.dump()
and dill.load()
are able to save and restore the object seamlessly.
- What causes the trouble for the
pickle
module? - Now that
dill
saves and reconstructs the object without any error, is there any way to verify if the pickling and unpickling withdill
went well? - How's it possible that
pickle
fails, butdill
succeeds?
pickle
doesn't handle functions or complex objects as well asdill
. I usedill
for all my Data Science pickling since the models and objects are very deep and complex – Powe