Python SCALE Codec Library
Low maintenance activity. Last release 5 days ago, commits in 1 of the last 26 weeks. Weaker on commit activity and release cadence.
$
pip install scalecodecPython SCALE Codec
Description
Substrate uses a lightweight and efficient encoding and decoding program to optimize how data is sent and received over the network. The program used to serialize and deserialize data is called the SCALE codec, with SCALE being an acronym for Simple Concatenated Aggregate Little-Endian.
Documentation
https://polkascan.github.io/py-scale-codec/
Installation
pip install scalecodec
Examples of different types
| Type | Description | Example SCALE decoding value | SCALE encoded value |
|---|---|---|---|
bool | Boolean values are encoded using the least significant bit of a single byte. | True | 0x01 |
u16 | Basic integers are encoded using a fixed-width little-endian (LE) format. | 42 | 0x2a00 |
Compact | A "compact" or general integer encoding is sufficient for encoding large integers (up to 2**536) and is more efficient at encoding most values than the fixed-width version. (Though for single-byte values, the fixed-width integer is never worse.) |