def load_object(file_path):
file_path = os.path.expanduser(file_path)
# reading to string and loads is 2.5x faster that using the file handle and load.
with open(file_path, 'rb') as fh:
data = fh.read()
try:
return pickle.loads(data, encoding='bytes')
except pickle.UnpicklingError as e:
raise ValueError from e
评论列表
文章目录