pure-protobuf
Protocol Buffers using Python type annotations
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 on this page — 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
pure-protobuf on PyPI
pip
pip install pure-protobufuv
uv add pure-protobufpoetry
poetry add pure-protobufInstalling 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 the current Python release (<4.0.0,>=3.9.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — get-annotations, typing-extensions |
| Maintenance | actively maintained — 346 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 79,503/month — #14,352 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pure_protobuf-3.1.5-py3-none-any.whl
Keywords: protobuf, protocol-buffers
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
opensearch-protobufsProvides pre-generated Python Protocol Buffer…
permissive · top 5,000 on PyPI
proto-schema-parserParses and generates Protobuf schema files…
permissive · top 15,000 on PyPI
proto-plusProto Plus wraps protocol buffers to provide…
permissive · top 1,000 on PyPI
protobuf3-to-dictConverts protocol buffer messages to Python…
permissive · top 5,000 on PyPI
protoc-gen-validateValidates protocol buffer messages against…
unclear · top 15,000 on PyPI
bbpbDecode and re-encode Protocol Buffer messages…
permissive · top 15,000 on PyPI
gtfs-realtime-bindingsProvides pre-generated Python classes for…
permissive · top 15,000 on PyPI
dbt-protosProvides Python Protocol Buffer bindings for…
permissive · top 1,000 on PyPI
protobuf-decoderDecodes protobuf binary messages without…
permissive · top 15,000 on PyPI
discord-protosProvides Python bindings for Discord's protocol…
permissive · top 15,000 on PyPI