fastproto
fastproto is an early work-in-progress compiler for generating small C++ header
files from .fastproto schema files. It is experimenting with a compact,
header-only serialization API for C++ projects.
The generated header includes the fastproto runtime, so consumers only need to include the one generated file.
Quick Start
Generate a header from a schema:
uv run fastproto -o generated.hpp example.fastproto
Use it from C++:
#include "generated.hpp"
fastproto::Factory<fastproto::generated::my_namespace::SimpleMessage> factory;
factory.set_simple_int_field(10);
auto serialized = factory.serialize();
fastproto::Parser<fastproto::generated::my_namespace::SimpleMessage> parser;
parser.parse(serialized);
auto value = parser.get_simple_int_field();
Build the example:
c++ -std=c++23 example.cpp -o example
Schema Syntax
Schemas are organized into namespaces and messages:
namespace my_namespace {
message SimpleMessage(1) {
simple_int_field : int32;
}
message MessageWithArray(3) {
my_array_field : array<SimpleMessage>;
}
}
Each message has a numeric magic value, which is used when validating parsed
buffers. Fields use name : type; syntax.
Currently supported field types include:
- Integers:
int8,int16,int32,int64,uint8,uint16,uint32,uint64 - Floating point:
float32,float64 boolstringarray<T>for arrays of simple types/messages- Other simple message types
Nested namespaces are supported with C++-style :: syntax:
namespace my_namespace::my_sub_namespace {
message Nested(2) {
value : int32;
}
}
CLI
Install the command from PyPI:
pip install fastproto-compiler
Then run:
fastproto -o generated.hpp example.fastproto
You can also run it without installing it globally with uv:
uvx --from fastproto-compiler fastproto -o generated.hpp example.fastproto
Run from the repo with uv:
uv run fastproto -o generated.hpp example.fastproto
For local development, install the command from the checkout:
uv tool install --editable .
If -o is omitted, the generated header is written to stdout.
Python Bindings
fastproto can also generate a small Python package containing pybind11 bindings for a schema:
fastproto --python-out fastproto_example example.fastproto
This creates ./fastproto_example with the generated C++ header, pybind11
binding source, pyproject.toml, CMakeLists.txt, and Python package glue. The
compiled extension module is named _fastproto_example and is installed inside
the fastproto_example package. In this mode, --python-out is the output
directory and package name, so -o is not used.
The generated directory looks like:
fastproto_example/
pyproject.toml
CMakeLists.txt
include/generated.hpp
src/fastproto_example_bindings.cpp
fastproto_example/__init__.py
Build the package with:
uv build fastproto_example
Or install it into the current environment:
uv pip install ./fastproto_example
Fastproto namespaces become Python submodules. For the top-level
example.fastproto, message factories and parsers are available under
fastproto_example.my_namespace:
from fastproto_example.my_namespace import SimpleMessageFactory, SimpleMessageParser
factory = SimpleMessageFactory()
factory.simple_int_field = 10
data = factory.serialize()
parser = SimpleMessageParser(data)
print(parser.simple_int_field)
Nested fastproto namespaces map to nested Python modules:
from fastproto_example.my_namespace.my_sub_namespace.my_next_sub_namespace import (
MessageWithStringFactory,
MessageWithStringParser,
)
factory = MessageWithStringFactory()
factory.my_int_field = 42
factory.my_string_field = "Hello from Python"
parser = MessageWithStringParser(factory.serialize())
print(parser.my_int_field, parser.my_string_field)
The Python binding generator is also early WIP. It currently emits a pybind11 package scaffold that can be built with scikit-build-core, and it embeds the Python binding runtime into the generated binding source.
Design Notes
fastproto is currently optimized for low-copy serialization and parsing on
common GCC/Clang targets. Generated messages use [[gnu::packed]] structs, and
parsers view caller-owned byte buffers directly instead of materializing decoded
objects.
That keeps the hot path small:
- Simple messages serialize as a span over the factory-owned struct.
- Strings parse as
std::string_viewinto the input buffer. - Arrays parse as spans or indexed views into the input buffer.
- Builtin scalar values are converted to/from network byte order.
The tradeoff is that this is not trying to be a maximally portable C++ wire format runtime. It assumes GCC/Clang-style packed-struct behavior on common architectures. The parser currently reinterprets bytes as generated structs, which is fast, but leans on compiler and platform behavior around packed layout, alignment, and object lifetime.
Status
This project is still early WIP. The schema language, generated C++ API, binary format, and runtime are all subject to change.
Metadata
Release files for fastproto-compiler 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastproto_compiler-0.0.1.tar.gz | 28.1 kB | With provenance | Details for fastproto_compiler-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastproto_compiler-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for fastproto_compiler-0.0.1-py3-none-any.whl |
Total release size: 46.8 kB
Release files / fastproto_compiler-0.0.1.tar.gz
| Download URL | fastproto_compiler-0.0.1.tar.gz |
|---|---|
| Size | 28.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bddd995b7ad6022ab1e8ddf67cd0c3b4aab7e5327a2e2164a571c070ca8cb77a
|
|
BLAKE2b-256 checksum How to use checksums |
795f2aa142fd6ee52776d3337c6bf840101894e1c4be1bfb2bbbe48b0677e705
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 28, 2026.
Transparency logRelease files / fastproto_compiler-0.0.1-py3-none-any.whl
| Download URL | fastproto_compiler-0.0.1-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a227b979f1614b41b81d895b4a460edc01ec155a17097f13a27814bd783eecc
|
|
BLAKE2b-256 checksum How to use checksums |
9cc6502bf571641168507988db5927955a9d278a65d559be4e6d1644aa19846c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 28, 2026.
Transparency logSecurity for fastproto-compiler 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for fastproto_compiler-0.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.