Data Serialization

https://farm3.staticflickr.com/2927/33467946364_3e59bd376a_k_d.jpg

What is data serialization?

Data serialization is the concept of converting structured data into a formatthat allows it to be shared or stored in such a way that its originalstructure to be recovered. In some cases, the secondary intention of dataserialization is to minimize the size of the serialized data which thenminimizes disk space or bandwidth requirements.

Pickle

The native data serialization module for Python is calledPickle.

Here’s an example:

importpickle#Here's an example dictgrades={'Alice':89,'Bob':72,'Charles':87}#Use dumps to convert the object to a serialized stringserial_grades=pickle.dumps(grades)#Use loads to de-serialize an objectreceived_grades=pickle.loads(serial_grades)

Protobuf

If you’re looking for a serialization module that has support in multiplelanguages, Google’sProtobuf library is an option.