Skip to content

New Documentation Site!

We are excited to announce the launch of our enhanced product documentation site for PyKX at docs.kx.com. It offers improved search capabilities, organized navigation, and developer-focused content. Please, take a moment to explore the site and share your feedback with us.

Compress and encrypt example

This example shows how to use various q compression and encryption algorithms on a PyKX table.

To follow along, download this zip archive that contains a copy of the python script and this writeup.

Here are the compression algorithms and their levels:

Algorithm Compression level
ipc 0
gzip 0-9
snappy 0
lz4hc 1-12

Quickstart

To run this example, execute the compress_and_encrypt.py file.

$ python compress_and_encrypt.py

Outcome

Writing in-memory trades table with gzip: {
    "compressedLength": 12503352,
    "uncompressedLength": 36666552,
    "algorithm": 2,
    "logicalBlockSize": 17,
    "zipLevel": 9
}

Writing in-memory trades table with snappy: {
    "compressedLength": 18911879,
    "uncompressedLength": 36666552,
    "algorithm": 3,
    "logicalBlockSize": 17,
    "zipLevel": 0
}

Writing in-memory trades table with lz4hc: {
    "compressedLength": 15233016,
    "uncompressedLength": 36666552,
    "algorithm": 4,
    "logicalBlockSize": 17,
    "zipLevel": 12
}

Writing on-disk trades table with lz4hc: {
    "compressedLength": 15233016,
    "uncompressedLength": 36666552,
    "algorithm": 4,
    "logicalBlockSize": 17,
    "zipLevel": 12
}

Loading master key

Writing in-memory trades table with lz4hc and encryption: {
    "compressedLength": 15240112,
    "uncompressedLength": 36666552,
    "algorithm": 20,
    "logicalBlockSize": 17,
    "zipLevel": 12
}