(obj, state_file)
Write state to a compressed pickle.
Write state to a compressed pickle.
Write state to a compressed pickle .
def save_session(obj, state_file):
    """Write state to a compressed pickle."""
    blob = zlib.compress(pickle.dumps(obj, pickle.HIGHEST_PROTOCOL))
    checksum = zlib.crc32(blob) & 0xffffffff
    header_dict = dict(checksum=checksum, **HEADER)
    header = struct.pack(HEADER_FORMAT, *(header_dict[_key] for _key in HEADER_KEYS))
    with open(state_file, 'wb') as out_file:
        out_file.write(header)
        out_file.write(blob)
def save_session ( obj , state_file ) : blob = zlib . compress ( pickle . dumps ( obj , pickle . HIGHEST_PROTOCOL ) ) checksum = zlib . crc32 ( blob ) & 0xffffffff header_dict = dict ( checksum = checksum , * * HEADER ) header = struct . pack ( HEADER_FORMAT , * ( header_dict [ _key ] for _key in HEADER_KEYS ) ) with open ( state_file , 'wb' ) as out_file : out_file . write ( header ) out_file . write ( blob )