pickle.loads()
pickle.loads() is a Python function in the Pickle Module category. Deserializes a Python object from bytes (instead of file). The syntax is pickle.loads(data, *, fix_imports=True, encoding="ASCII", errors="strict"). Parameters: data — bytes. Returns: Deserialized object. A typical example: obj = pickle.loads(pickle.dumps([1,2,3]))
# obj = [1,2,3]. A close sibling is pickle.dump(), which serializes a Python object and writes it to a file. A close sibling is pickle.load(), which deserializes a Python object from a pickle file. A close sibling is pickle.dumps(), which serializes a Python object to bytes (instead of file). A close sibling is pickle.HIGHEST_PROTOCOL, which an integer representing the highest available pickle protocol version. More about this category: Python object serialization — dump, load, dumps, loads, protocols. For a broader walkthrough, read the Pickle Module guide. Related Pickle Module entries: pickle.dump(), pickle.load(), pickle.dumps(), pickle.HIGHEST_PROTOCOL. This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.