Pickling Without a File
We'll cover the following...
The examples in the previous section showed how to serialize a Python object directly to a file on disk. But what if you don’t want or need a file? You can also serialize to a bytes
object in memory.
Press + to interact
import pickleshell = 1print (shell)#1with open('entry.pickle', 'rb') as f:entry = pickle.load(f)b = pickle.dumps(entry) #①print (type(b)) #②#<class 'bytes'>entry3 = pickle.loads(b) #③print (entry3 == entry) #④#True
① The ...