Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference between Pickling and Serialization?

I have came across these two terms so often while reading about python objects. However, there is a confusion between pickling and serialization since at one place I read

The pickle module implements an algorithm for turning an arbitrary Python object into a series of bytes. This process is also called serializing” the object.

If serializing and pickling is same process, why use different terms for them?

like image 326
Ajay Gupta Avatar asked Mar 16 '23 12:03

Ajay Gupta


1 Answers

You are misreading the article. Pickling and serialisation are not synonymous, nor does the text claim them to be.

Paraphrasing slighly, the text says this:

This module implements an algorithm for turning an object into a series of bytes. This process is also called serializing the object.

I removed the module name, pickle, deliberately. The module implements a process, an algorithm, and that process is commonly known as serialisation.

There are other implementations of that process. You could use JSON or XML to serialise data to text. There is also the marshal module. Other languages have other serialization formats; the R language has one, so does Java. Etc.

See the WikiPedia article on the subject:

In computer science, in the context of data storage, serialization is the process of translating data structures or object state into a format that can be stored (for example, in a file or memory buffer, or transmitted across a network connection link) and reconstructed later in the same or another computer environment.

Python picked the name pickle because it modelled the process on how this was handled in Modula-3, where it was also called pickling. See Pickles: Why are they called that?

like image 59
Martijn Pieters Avatar answered Apr 16 '23 16:04

Martijn Pieters