Pure Python Flatbuffer Schema Compiler
Project description
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
Running
$ 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flattools-0.6.tar.gz
.
File metadata
- Download URL: flattools-0.6.tar.gz
- Upload date:
- Size: 30.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd2ec9caf965f1b0fcd76040db801e88dffd1044b7ab4bfcc4fae8d3e225a2aa |
|
MD5 | e5da4bfc28a1bd66d8276a3127ca36a6 |
|
BLAKE2b-256 | aa4668ca1de5bf84fa0f021016670a95301f435476bee3d1070e8fc042f1d048 |
File details
Details for the file flattools-0.6-py2.py3-none-any.whl
.
File metadata
- Download URL: flattools-0.6-py2.py3-none-any.whl
- Upload date:
- Size: 38.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93f203986bd7a90ff1ba7a1ebe5a81e28e8a5f853435be7341dc5ad27dcc338d |
|
MD5 | 02b84417120d71ae9b2db218b83043cc |
|
BLAKE2b-256 | fdf7c55778f2b9ab4ecd5525423e202a2fce8ad3e30e8ac1132db73f797d9bf9 |