skillfed

pure-protobuf

Protocol Buffers using Python type annotations

pure-protobuf v3.1.5 79.5K downloads/30d#14,352 on PyPI291
Permissive license MIT Active released

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-protobuf

uv

uv add pure-protobuf

poetry

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 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

protobuf serialization without code generationprotocol buffers python annotationspure python protobufprotobuf dataclass serializationtype-annotated message encoding
serializationprotocol-bufferstype-annotations

More Libraries packages