Skip to main content

A compact serializer aiming for flexibility and performance

Project description

Compaqt

A compact serializer aiming for flexibility and performance.

Installation

To install this module for Python, simply run this: pip install compaqt

About this serializer

Compaqt is a serializer designed to strike a balance between compact data representation and performance. According to benchmarks compared to other existing serialization methods, this one performs well in both compactness and (de-)serialization speed.

In an attempt to keep the memory usage low, Compaqt attempts to predict how much memory to allocate before serializing data, by dynamically learning based on previously received data. This is to avoid over-allocating memory by large amounts, while also reducing re-allocations. This - besides the lower memory footprint - also enhances performance due to the ease of upfront allocation and minimal re-allocations during the process.

The serializer currently supports the following datatypes:

  • bytes
  • str
  • int
  • float
  • complex
  • bool
  • NoneType
  • list
  • dict

Usage

Encoding (serializing):

# The value we want to encode
value = {
    'Hello,': 'world!',
    'this is a': ['test', 'value']
}

# Call the `encode` method to encode the value
encoded = compaqt.encode(value)

# Now, `encoded` contains the value serialized to bytes

Decoding (de-serializing):

# Our encoded value (generated from the value from 'Encoding' above)
encoded = b'!cHello,cworld!\x93this is a CtestSvalue'

# call the `decode` method to decode the value
value = compaqt.decode(encoded)

# Now, `value` contains the original value

For further usage or other documentation, see the docs.

License

This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.

Contact

Feel free to reach out via the GitHub repository of this module (github) or reach out by mail (Sven Boertjens).

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

compaqt-0.4.1.tar.gz (18.6 kB view details)

Uploaded Source

File details

Details for the file compaqt-0.4.1.tar.gz.

File metadata

  • Download URL: compaqt-0.4.1.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.1.dev0+g94f810c.d20240510 CPython/3.12.7

File hashes

Hashes for compaqt-0.4.1.tar.gz
Algorithm Hash digest
SHA256 4d06786c5031bccae5a03d8eb3209b39eb84db15d3aa3282bf34ead1078ecff5
MD5 9c70b205fa5ffbcfb4aad1ca42ff62fd
BLAKE2b-256 64bf76e3f87d3d95073efb520ae6263e2d9a9e4f5e3d7111f097a6cbd50959dd

See more details on using hashes here.

Supported by

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