Library for saving and loading python instance to a file.

dump to file

with open("object.pkl", "wb") as f:
    pickle.dump(object, f)

load from file

with open("object.pkl", "rb") as f:
    object = pickle.load(f)

dump to bytes object

bytes = pickle.dumps(object)

load from bytes object

object = pickle.loads(bytes)

Instances supporting pickle

  • None, True, False
  • Int, Float, Complex
  • String, bString, bArray
  • Tuple that containing pickle-able instances
  • Functions
  • Classes
  • Built-in functions
  • Classes whose results of __dict__ and __getstate__ is pickle-able