Python Pickle File
4.0 | 37 Votes
What is a PKL file?
A PKL file is a file created by pickle, a Python module that enabless objects to be serialized to files on disk and deserialized back into the program at runtime. It contains a byte stream that represents the objects.
The process of serialization is called "pickling," and deserialization is called "unpickling." A PKL file is pickled to save space when being stored or transferred over a network then is unpickled and loaded back into program memory during runtime. The PKL file is created using Python pickle and the dump() method and is loaded using Python pickle and the load() method.
There are three protocols used for pickling:
- Version 0 - The original ASCII protocol, which is backwards compatible with earlier Python versions.
- Version 1 - The old binary format, which is backwards compatible with earlier Python versions.
- Version 2 - Python 2.3 format, which features more efficient pickling of new style classes.