有使用 Protocol Buffer 的经验吗?

发布于 2024-07-04 00:41:58 字数 278 浏览 7 评论 0原文

我只是浏览了有关 Google 的协议缓冲区数据交换格式的一些信息。 有没有人使用过这些代码,甚至围绕它创建了一个项目?

我目前正在 Python 项目中使用 XML 在文本编辑器中手动创建结构化内容,我想知道人们对 Protocol Buffers 作为面向用户的输入格式的普遍看法是什么。 速度和简洁的好处似乎确实存在,但在实际生成和处理数据时,有很多因素。

I was just looking through some information about Google's protocol buffers data interchange format. Has anyone played around with the code or even created a project around it?

I'm currently using XML in a Python project for structured content created by hand in a text editor, and I was wondering what the general opinion was on Protocol Buffers as a user-facing input format. The speed and brevity benefits definitely seem to be there, but there are so many factors when it comes to actually generating and processing the data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

虚拟世界 2024-07-11 00:41:58

像PB这样的二进制格式的另一个缺点是,如果有一个错误,整个数据文件就无法解析,但是使用JSON或XML,作为最后的手段,你仍然可以手动修复错误,因为它是人类可读的并且具有内置冗余..

Another drawback of binary format like PB is that if there is a single bit of error, the entire data file is not parsable, but with JSON or XML, as the last resort you can still manually fix the error because it is human readable and has redundancy built-in..

忘年祭陌 2024-07-11 00:41:58

从您的简短描述来看,协议缓冲区似乎不合适。 “在文本编辑器中手工创建的结构化内容”这句话几乎是对 XML 的呼喊。

但是,如果您希望与不在组织外部共享的数据结构进行高效、低延迟的通信,那么协议缓冲区等二进制序列化可以提供巨大的优势。

From your brief description, it sounds like protocol buffers is not the right fit. The phrase "structured content created by hand in a text editor" pretty much screams for XML.

But if you want efficient, low latency communications with data structures that are not shared outside your organization, binary serialization such as protocol buffers can offer a huge win.

帅的被狗咬 2024-07-11 00:41:58

如果您正在寻找面向用户的交互,请坚持使用 xml。 目前它得到了更多的支持、理解和普遍接受。 如果它是内部的,我会说协议缓冲区是一个好主意。

也许几年后,随着更多工具的出现来支持协议缓冲区,然后开始寻找面向公众的 API。 在那之前... JSON

If you are looking for user facing interaction, stick with xml. It has more support, understanding, and general acceptance currently. If it's internal, I would say that protocol buffers are a great idea.

Maybe in a few years as more tools come out to support protocol buffers, then start looking towards that for a public facing api. Until then... JSON?

你如我软肋 2024-07-11 00:41:58

协议缓冲区旨在优化机器之间的通信。 它们确实不适合人类互动。 此外,该格式是二进制的,因此在该用例中它无法替代 XML。

我还推荐 JSON 作为最紧凑的基于文本的格式。

Protocol buffers are intended to optimize communications between machines. They are really not intended for human interaction. Also, the format is binary, so it could not replace XML in that use case.

I would also recommend JSON as being the most compact text-based format.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文