FlatBuffers

Google's memory-efficient, zero-copy serialization library for cross-language data exchange

Library
PyPI
v25.12.19
26,335stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
75/100Good
Development Activity60
Maintenance48
Community92
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
80/100Excellent
Architecture88
Code Quality82
Innovation90
Learning Curve60

FlatBuffers is Google’s serialization library designed so that encoded data can be accessed directly from a buffer without unpacking or copying it into intermediate objects first. A schema file (.fbs) defines your data’s structure, and the flatc compiler generates bindings for over a dozen languages including Python, C++, Java, Rust, Go, TypeScript, and Swift, all reading the exact same wire format.

The Python package wraps the generated table/vector accessors around a Builder class for encoding, and generated schema classes for zero-copy decoding directly from bytes, making FlatBuffers a strong fit anywhere serialization speed and memory footprint matter more than raw ergonomics — game engines, mobile apps, gRPC services, and other performance-sensitive cross-language systems.

What You Get

  • A flatc schema compiler that generates strongly-typed accessor code for Python (and 12+ other languages) from a single .fbs schema definition
  • A Builder class in builder.py implementing the buffer-construction algorithm (vtables, offsets, alignment/padding) shared across all language bindings
  • Zero-copy read access — generated table classes index directly into the received byte buffer instead of deserializing into new objects
  • FlexBuffers, a schema-less companion format (flexbuffers.py) for cases where a fixed schema isn’t available upfront
  • Cross-language wire-format compatibility, so a buffer built in one language’s binding can be read unmodified in any other

Common Use Cases

  • Serializing game state or asset data in engines where per-frame allocation and parsing overhead must be minimized
  • Exchanging structured data between services written in different languages that all need to read the same binary payloads
  • Mobile and embedded applications where memory footprint and decode latency are tightly constrained
  • Building on top of gRPC as an alternative wire format to Protobuf when zero-copy access is the priority

Under The Hood

Architecture - The Python package (python/flatbuffers/) is a runtime library, not the compiler: builder.py implements the encode-side algorithm (vtable deduplication, offset tracking, alignment), table.py provides the generic zero-copy read primitives that flatc-generated schema classes build on, and flexbuffers.py implements the parallel schema-less format independently of the vtable/table machinery. Tech Stack - Pure Python with no runtime dependencies beyond the standard library; number_types.py and packer.py wrap struct for the low-level binary packing, and compat.py smooths over Python 2/3 differences still present in the codebase. Code Quality - The Python bindings are one language target inside a much larger polyglot monorepo (C++, Rust, Java, Go, TypeScript, Swift, and more all under the same tests/ and .fbs schema fixtures), so the Python-specific test surface (tests/PythonTest.sh) is exercised as part of a cross-language CI matrix rather than in isolation, with py.typed present for type-checker consumers. API Design - The generated code is intentionally low-level and mechanical (typed getters mirroring the schema, an imperative Builder.Start*/End* construction sequence), which is fast and predictable but requires learning FlatBuffers’ own construction protocol rather than exposing idiomatic native Python objects.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search