Skip to main content

Flattools - collection of tools to deal with Flatbuffers

Flatbuffers is a cross platform serialization library with a focus on zero copy deserialization. They're similar in functionality to protocol buffers and thrift, but with a focus on gaming related use cases where the CPU cost of decoding large buffers can be significant.

Flattools implements an alternative flatbuffers compiler implemented in python, referred to as flatc.py. The idea is that we could use flatbuffers as a serialization agnostic IDL.

Why is this important? Building software around a well defined type system that expresses various concepts in a given domain such as banking or gaming (also knows as domain driven design) is a useful technique, but somewhat controversial.

Usage

Installing

uv sync --extra dev

Running

uv run flatc.py tests/parser-cases/color.fbs --kotlin=1

Generates something like

    // automatically generated by the FlatBuffers compiler, do not modify
    enum class Color(val x: Byte) {
        Red(1),
        Green(2),
        Blue(3),
    }

    data class Person(
        val name: String,
        val address: String,
        val age: Short,
        val length: ULong,
        val favorite_color: Color,
    )

    data class Product(
        val label: String,
        val price: Int,
    )

    sealed class Item {
        class Product : Item()
        class Person : Item()
    }

This uses templated code generation using jinja2.

Supported languages: python, rust, kotlin, swift

Supporting new languages

Pull requests are welcome for other languages. The idea is to start from one of the existing languages here and creating a new template for your language of choice.

There are existing tests, so all you need to do is generate golden/expected data for your language of choice

Metadata

Release files for flattools 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flattools 0.6.3
File Size Uploaded
flattools-0.6.3.tar.gz 27.7 kB Details

Release files / flattools-0.6.3.tar.gz

Download URL flattools-0.6.3.tar.gz
Size 27.7 kB
Tags Source
SHA-256 checksum
How to use checksums
774edc5d684deac676736853ac97f318683c5901c8bc99dbdb4ebe465dc34b60
BLAKE2b-256 checksum
How to use checksums
5dce8f8b36cafc918bc8a44e867c4890907b88c4fcf33912ffd067a668a83895
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.6.3 This release

1 release file

0.6.2

2 release files

0.6

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page