def _save(path, obj): "Save an object to the specified path." data = zlib.compress(pickletools.optimize(pickle.dumps(obj)), 9) with open(path, 'wb') as file: file.write(data)