From dc7ab964b6e47233c7c588e780fbf946d52ec188 Mon Sep 17 00:00:00 2001 From: Vopaaz Date: Wed, 15 Nov 2023 18:51:35 -0800 Subject: [PATCH] Remove unused lines --- checkpointing/util/pickle.py | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/checkpointing/util/pickle.py b/checkpointing/util/pickle.py index dc703c2..7da2ecf 100644 --- a/checkpointing/util/pickle.py +++ b/checkpointing/util/pickle.py @@ -1,34 +1,11 @@ from io import IOBase import pickle from typing import Any -from checkpointing.config import defaults - -try: - import pickle5 -except ImportError: - pass - - -def get_pickle_module(protocol: int): - """ - Returns: - built-in pickle module if the given protocol is supported. - Otherwise check if the protocol = 5, if so, use pickle5. - """ - - if protocol <= pickle.HIGHEST_PROTOCOL: - return pickle - - elif protocol == 5: - return pickle5 - - else: - raise RuntimeError(f"pickle protocol {protocol} is not supported") def dump(obj: Any, file: IOBase, protocol: int) -> None: - return get_pickle_module(protocol).dump(obj, file, protocol) + return pickle.dump(obj, file, protocol) def load(file: IOBase, protocol: int) -> Any: - return get_pickle_module(protocol).load(file) + return pickle.load(file)