Python Pickle Module Constants

The constants provided by the Python Pickle Module:

Constant Name

Description

 

Pickle Protocol Version Related:

  • These constants are to represent the pickle protocol versions.
  • Higher the Version Number more refined and improvised serialization features are available to the pickling process.
  • Lower the version number, the pickling and the related data exchange is supported with the earlier python versions.
  • These constants are typically used while making the pickle module function calls load(), loads(),dump() and dumps()

pickle.HIGHEST_PROTOCOL

Returns the highest pickle protocol version of the Python installation.

pickle.DEFAULT_PROTOCOL

Returns the default pickle protocol version of the Python installation.

 

Example:

Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 03:13:28)

[Clang 6.0 (clang-600.0.57)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import pickle

>>> pickle.HIGHEST_PROTOCOL

4

>>> pickle.DEFAULT_PROTOCOL

3

>>>


Copyright 2023 © pythontic.com