Skip to main content

Code-generation library and tool for the BlitzBuffers serialization format

Project description

⚡BlitzBuffers

BlitzBuffers is a serialization format and code-generator that makes it fast and easy to interface with the underlying data.

The main purposes of BlitzBuffers is performance, versatility, and ease of use.

Pros

  • Very fast serialization and deserialization of data.
  • Cross-language support via code generation based on a given schema file.
  • Simple, but powerful schema syntax featuring structs, enums, tagged unions, vectors, and strings.
  • Zero-copy serialization and deserialization - directly reads from and writes to the buffer.
  • Easy-to-use API via the generated code.
  • Code generation is done by via Python, which makes it simple to integrate into your workflow, instead of having to deal with executables or build steps of other projects.

Cons

  • Unset fields take up space in the buffer.
  • No easy schema versioning.
  • Not many languages supported (yet).
  • No endianness checks in C++ (yet) - only use it on little-endian machines.

Schema

The schema syntax and capabilities take inspiration from the Rust language.

Expand to see an example using the various constructs.
namespace game

enum EntityType {
    Player
    Neutral
    Enemy
}

struct Position {
    x: f32
    y: f32
    z: f32
}

struct Entity {
    type: EntityType
    name: string
    hitpoints: u64
    position: Position
    traits: Trait[]
}

enum Trait {
    Height(u16, u16),

    Color {
        red: u8
        green: u8
        blue: u8
        alpha: u8
    }

}

Installation

The code-generation tool can be installed via pip:

pip3 install blitzbuffers

Code generation

Code for the desired languages can be generated by calling the module directly. You can specify one or more languages in a single command-line:

python3 -m blitzbuffers <schema-path> [-l <language> <output-file-path>]

Available languages are currently: cpp, rust

Benchmarks

A few benchmarks showing the difference between blitzbuffers and other tools/libraries with similar functionality.

C++

Deserialization/usage is the same for blitzbuffers no matter the setup.

Setup Serialization Deserialization/Usage (checked) Roundtrip
Blitzbuffers (fixed) 34.8 ns 74.7 ns 125 ns
Blitzbuffers (expanding) 105 ns 74.8 ns 187 ns
Flatbuffers 433 ns 176 ns 620 ns
alpaca 218 ns 479 ns 717 ns

Rust

Deserialization/usage is the same for blitzbuffers no matter the setup. Checked vs. unchecked, is whether the data buffer is verified before the data in it is used.

Setup Serialization Deserialization/Usage (checked) Deserialization/Usage (unchecked)
Blitzbuffers (fixed) 77.3 ns 181.4 ns 116.8 ns
Blitzbuffers (expanding) 141.1 ns - -
Blitzbuffers (raw first) 593.8 ns - -
Blitzbuffers (raw storage) 107.1 ns - -
Flatbuffers 410.8 ns 595.9 ns 129.9 ns

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blitzbuffers-0.1.1.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blitzbuffers-0.1.1-py3-none-any.whl (40.2 kB view details)

Uploaded Python 3

File details

Details for the file blitzbuffers-0.1.1.tar.gz.

File metadata

  • Download URL: blitzbuffers-0.1.1.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for blitzbuffers-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8f547bf61c7c7b77529e21dc55f47c2ef4147a679fe48090e5891879daef3cae
MD5 c801e4218f7647903d857afa3f82b926
BLAKE2b-256 888d72811c967c144753e82c2d1d3c9a130bb3500b371bf70e3821dfaf9fa221

See more details on using hashes here.

File details

Details for the file blitzbuffers-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: blitzbuffers-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 40.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for blitzbuffers-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 166556bae42d96972df1baa53af0b02031dcabbcc4c879eeb7d0e81f1b98050c
MD5 e80ef2bdde84719ce7253d0addc4e2d0
BLAKE2b-256 a8833d16e63fd84b1e8d61c4c97288921d7f0f72348d9edd7233cb42e96d77c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page