/beretta

BERT (de)serialization module

Primary LanguagePythonMIT LicenseMIT

beretta Build Status

BERT serializer for your Pythons.

Installation

$ apt-get install python-dev
$ pip install beretta

Usage

import beretta

binary = beretta.encode([{'key': 'value'}, 42]) # => b'\x83l\x00...'
beretta.decode(binary) # => [{'key': 'value'}, 42]

data = [0 for _ in range(1024)]
compressed = beretta.encode(data, compressed=6)
assert len(compressed) < len(beretta.encode(data))

Datatypes representation

Type Python BERT
Time datetime.datetime {bert, time, Megaseconds, Seconds, Microseconds}
Dictionary dict {bert, dict, KeysAndValues}
Boolean True or False {bert, true} or {bert, false}
Nil None {bert, nil}
Regex re.compile {bert, regex, Source, Options}