Getting started with Protobuffer and Python

Getting started with Protobuffer and Python

Getting started with Protobuffer and Python. I am going to talk about Proto Buffers and how you can use them in Python for passing messages across networks. Protocol…

In this post, I am going to talk about Proto Buffers  and how you can use them in Python for passing messages across networks. Protocol Buffers or Porobuf  in short, are used for data serialization and deserialization. Before I discuss Protobuf, I would like to discuss data serialization and serialization first.

Data Serialization and De-serialization

According to Wikipedia

Serialization is the process of translating a [data structure_](https://en.wikipedia.org/wiki/Data_structure) or [object_](https://en.wikipedia.org/wiki/Object_(computer_science))_ state into a format that can be stored (for example, in a [file_](https://en.wikipedia.org/wiki/Computer_file)_ or memory [data buffer_](https://en.wikipedia.org/wiki/Data_buffer)) or transmitted (for example, over a [computer network_](https://en.wikipedia.org/wiki/Computer_network)) and reconstructed later (possibly in a different computer environment)_

In simple words, you convert simplex and complex data structures and objects into byte streams so that they could be transferred to other machines or store in some storage.

Data deserialization is the reverse process of it to restore the original format for further usage.

Data serialization and vice versa is not something Google invented. Most of the programming languages support it. Python provides pickle, PHP provides serialize function. Similarly, many other languages provide similar features. The issue is that these serialization/deserialization mechanisms are not standardized and only useful if both source and destination are using the same language. There was a need for some standard format that could be used across the system irrespective of the underlying programming language.

You might wonder, hey, why not just use XML or JSON? the issue is that these formats are in text form and they could get huge if the data structure is big and could make things slow if sent across the network. Protobuf on other hand is in binary format and could be smaller in size if a large amount of data is sent.

On another hand, Protobuf is not the first data serialization format that is available in binary format. BSON(Binary JSON) developed by MongoDB and MessagePack also supports such facilities.

Google’s Protobuf is not all about data exchange. It also provides a set of rules to define and exchange these messages. On top of it, it is heavily used in gRPC, Google’s way of Remote Procedure Calls. Hence, if you are planning to work on gRPC in any programming language you must have an idea of writing .proto files.

data-serialization python protobuf

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

top 30 Python Tips and Tricks for Beginners

In this post, we'll learn top 30 Python Tips and Tricks for Beginners

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.

Your Data Architecture: Simple Best Practices for Your Data Strategy

Your Data Architecture: Simple Best Practices for Your Data Strategy. Don't miss this helpful article.

Data Science With Python Training | Python Data Science Course | Intellipaat

🔵 Intellipaat Data Science with Python course: https://intellipaat.com/python-for-data-science-training/In this Data Science With Python Training video, you...

Lambda, Map, Filter functions in python

You can learn how to use Lambda,Map,Filter function in python with Advance code examples. Please read this article