Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

protocol buffers - Fastest way to parse protobuf message in python (currently I am using MessageToDict)

My python server is receiving streaming protobuf message and each message is quite big. Currently, I am using MessageToDict to parse the protobuf message. However, I feel it is very slow.

in term of protobuf definition:

message Student {
     string name = 1;
     string ago = 2;
     string address = 3;
     string email = 4;
}

message Student {
     repeated Person = 1;
}

In terms of Python code:

from google.protobuf.json_format import MessageToDict
items = MessageToDict(university_msg)

the university_msg has many students so it will take a few seconds to convert university_msg to items dictionary.

So I am just wondering anyone know is there a faster way to convert university_msg to items ?

question from:https://stackoverflow.com/questions/66067237/fastest-way-to-parse-protobuf-message-in-python-currently-i-am-using-messagetod

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...