[PYTHON] Serialization with cPickle, gzip

[Personal memo] It's a fixed form, but I sometimes forget it, so make a memo.

dump.py


import gzip
import cPickle

obj = 1

with gzip.open('test.pkl.gz', 'wb') as gf:
    cPickle.dump(obj, gf, cPickle.HIGHEST_PROTOCOL)

load.py


with gzip.open('test.pkl.gz', 'rb') as gf:
   x = cPickle.load(gf)

Recommended Posts

Serialization with cPickle, gzip
Send CSS compressed to Gzip with Flask
Print memos with a receipt printer (serialization)