Skip to content

Commit 5ce9c8a

Browse files
committed
Added serialization.rst file to scenarios.
1 parent dbef555 commit 5ce9c8a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/scenarios/serialization.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
==================
2+
Data Serialization
3+
==================
4+
5+
What is data serialization?
6+
---------------------------
7+
8+
Data serialization is the concept of converting structured data into a format
9+
that allows it to be shared or stored in such a way that its original
10+
structure to be recovered. In some cases, the secondary intention of data
11+
serialization is to minimize the size of the serialized data which then
12+
minimizes disk space or bandwidth requirements.
13+
14+
Pickle
15+
------
16+
17+
The native data serialization module for Python is called `Pickle
18+
<https://docs.python.org/2/library/pickle.html>`_.
19+
20+
Here's an example:
21+
22+
.. code-block:: python
23+
24+
import pickle
25+
26+
#Here's an example dict
27+
grades = { 'Alice': 89, 'Bob': 72, 'Charles': 87 }
28+
29+
#Use dumps to convert the object to a serialized string
30+
serial_grades = pickle.dumps( grades )
31+
32+
#Use loads to de-serialize an object
33+
received_grades = pickle.loads( serial_grades )
34+
35+
Protobuf
36+
--------
37+
38+
If you're looking for a serialization module that has support in multiple
39+
languages, Google's `Protobuf
40+
<https://developers.google.com/protocol-buffers>`_ library is an option.

0 commit comments

Comments
 (0)