--- id: pure-protobuf version: "3.1.5" license: MIT license_treatment: permissive maintenance: active --- # pure-protobuf — Protocol Buffers using Python type annotations License: permissive · Maintenance: active · Downloads: 79.5K/mo ## What it is and what it does pure-protobuf lets you define Protocol Buffer messages using Python type annotations and dataclasses instead of `.proto` files and code generation. You annotate fields with Field(n) markers, inherit from BaseMessage, and the library handles serialization to and deserialization from protobuf wire format. It works with both plain dataclasses and Pydantic models, making it useful when you want protobuf's compact binary format without the separate schema compilation step. The package depends on get-annotations and typing-extensions for runtime type introspection and annotation support across Python versions. It's actively maintained, supports Python 3.9 through 3.13, and carries no known security vulnerabilities. The annotation-driven approach trades the explicit schema definition of traditional protobuf for tighter integration with Python's type system. Use it for: - Serialize and deserialize messages in microservices that need compact binary format without maintaining separate `.proto` files. - Add protobuf support to existing dataclass or Pydantic models without code generation or schema compilation steps. - Build RPC or message-passing systems where message definitions live alongside Python type hints. - Store or transmit structured data in protobuf format when you prefer Python annotations over schema files. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Encodes and decodes Protocol Buffer messages using Python type annotations, without requiring `.proto` files or code generation. Yes. Low install friction, active maintenance, permissive license, no vulnerabilities, and a clean annotation-based API make it a solid choice if you need protobuf serialization without code generation. Best suited for projects where keeping message definitions in Python code is a net win over managing `.proto` files—verify first that it handles the full range of protobuf types your use case requires. ## Install pip install pure-protobuf uv add pure-protobuf poetry add pure-protobuf ## Installing pure-protobuf Before you install: Low friction: pure Python wheel with only two lightweight runtime dependencies (get-annotations and typing-extensions). Active maintenance with recent commits and stable production status. License in practice: MIT license permits unrestricted use, modification, and distribution in both open and closed-source projects. Quickstart: from dataclasses import dataclass from io import BytesIO from pure_protobuf.annotations import Field from pure_protobuf.message import BaseMessage from typing_extensions import Annotated @dataclass class SearchRequest(BaseMessage): query: Annotated[str, Field(1)] = "" page_number: Annotated[int, Field(2)] = 0 request = SearchRequest(query="hello", page_number=1) buffer = bytes(request) recovered = SearchRequest.read_from(BytesIO(buffer)) Requires Python 3.9 or later. Verify before relying: - Whether the package handles nested messages, repeated fields, and all protobuf3 types beyond the basic examples shown. - Performance characteristics compared to the official protobuf library for large message volumes. - Compatibility with existing `.proto` schemas or whether it is strictly annotation-driven. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 79.5K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags protobuf serialization without code generation, protocol buffers python annotations, pure python protobuf, protobuf dataclass serialization, type-annotated message encoding, serialization, protocol-buffers, type-annotations [View on SkillFed](https://skillfed.io/packages/pure-protobuf) · [View on PyPI](https://pypi.org/project/pure-protobuf/)