You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
631 B
24 lines
631 B
from typing import Optional
|
|
|
|
from . import cloudpickle
|
|
from .util import JSONInput, JSONOutput
|
|
|
|
|
|
def pickle_dumps(data: JSONInput, protocol: Optional[int] = None) -> bytes:
|
|
"""Serialize a Python object with pickle.
|
|
|
|
data: The object to serialize.
|
|
protocol (int): Protocol to use. -1 for highest.
|
|
RETURNS (bytes): The serialized object.
|
|
"""
|
|
return cloudpickle.dumps(data, protocol=protocol)
|
|
|
|
|
|
def pickle_loads(data: bytes) -> JSONOutput:
|
|
"""Deserialize bytes with pickle.
|
|
|
|
data (bytes): The data to deserialize.
|
|
RETURNS: The deserialized Python object.
|
|
"""
|
|
return cloudpickle.loads(data)
|