Skip to main content

Library for read compressed stream and write compressed chunks.

Project description

Light Compressor

This library is designed to provide optimal decompression and compression speed for data streams from databases and files. My project requires maximum-speed processing of byte streams and transferring compressed data to another stream. After testing all available solutions, I found their speed unsatisfactory, so I optimized the existing implementation to achieve better performance.

The stream reader use direct sequential reading from the stream with explicit size indication. This meets all requirements for my project. Supported compression formats: LZ4 and ZSTD only.

Examples

File detect compression only

from light_compressor import auto_detector
fileobj = open("some_path_to_file.bin", "rb")
compressor_method = auto_detector(fileobj)

File reading

When reading from files, automatic compression format detection is available (checks for LZ4/ZSTD signatures or no compression):

from light_compressor import define_reader
fileobj = open("some_path_to_file.bin", "rb")
decompressed_stream = define_reader(fileobj)

File writing

from light_compressor import (
    LZ4Compressor,
    ZSTDCompressor,
)
# some data in bytes
bytes_data: list[bytes]
# for example we using ZSTDCompressor
compressor = ZSTDCompressor()
fileobj = open("some_path_to_file.bin", "wb")

for data in compressor.send_chunks(bytes_data):
    fileobj.write(data)

print("Original size is:", compressor.decompressed_size)
print("Compressed size is:", fileobj.tell())

fileobj.close()

Stream reading

For stream processing, the compression method must be explicitly specified

from light_compressor import (
    define_reader,
    CompressionMethod,
)
compressed_stream: urllib3.response.HTTPResponse
# Get decompressed file-like object from ZSTD-compressed stream
decompressed_stream = define_reader(compressed_stream, CompressionMethod.ZSTD)

Stream writing

from light_compressor import (
    define_writer,
    CompressionMethod,
)
# some data in bytes
bytes_data: list[bytes]
# Get generator yielding ZSTD-compressed byte chunks
compressed_stream = define_writer(bytes_data, CompressionMethod.ZSTD)

Installation

From pip

pip install light-compressor

From local directory

pip install .

From git

pip install git+https://github.com/0xMihalich/light_compressor

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

light_compressor-0.0.2.1-cp314-cp314-win_amd64.whl (150.9 kB view details)

Uploaded CPython 3.14Windows x86-64

light_compressor-0.0.2.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (979.1 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

light_compressor-0.0.2.1-cp314-cp314-macosx_11_0_arm64.whl (168.6 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

light_compressor-0.0.2.1-cp314-cp314-macosx_10_15_x86_64.whl (162.9 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

light_compressor-0.0.2.1-cp313-cp313-win_amd64.whl (147.2 kB view details)

Uploaded CPython 3.13Windows x86-64

light_compressor-0.0.2.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (991.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

light_compressor-0.0.2.1-cp313-cp313-macosx_11_0_arm64.whl (166.6 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

light_compressor-0.0.2.1-cp313-cp313-macosx_10_14_x86_64.whl (162.3 kB view details)

Uploaded CPython 3.13macOS 10.14+ x86-64

light_compressor-0.0.2.1-cp312-cp312-win_amd64.whl (149.2 kB view details)

Uploaded CPython 3.12Windows x86-64

light_compressor-0.0.2.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

light_compressor-0.0.2.1-cp312-cp312-macosx_11_0_arm64.whl (169.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

light_compressor-0.0.2.1-cp312-cp312-macosx_10_14_x86_64.whl (164.9 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

light_compressor-0.0.2.1-cp311-cp311-win_amd64.whl (150.8 kB view details)

Uploaded CPython 3.11Windows x86-64

light_compressor-0.0.2.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (957.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

light_compressor-0.0.2.1-cp311-cp311-macosx_11_0_arm64.whl (168.0 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

light_compressor-0.0.2.1-cp311-cp311-macosx_10_14_x86_64.whl (163.2 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

light_compressor-0.0.2.1-cp310-cp310-win_amd64.whl (151.2 kB view details)

Uploaded CPython 3.10Windows x86-64

light_compressor-0.0.2.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (908.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64manylinux: glibc 2.5+ x86-64

light_compressor-0.0.2.1-cp310-cp310-macosx_11_0_arm64.whl (169.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

light_compressor-0.0.2.1-cp310-cp310-macosx_10_14_x86_64.whl (164.3 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

Details for the file light_compressor-0.0.2.1-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 fc171544fc7ff2618a418455c2c9d6d947f718162460681b75a82911d8d9eaaf
MD5 df970fc062a027e0817aefe97bab277d
BLAKE2b-256 aa4146f1ea97c1c409a9f53111c6f21e1dd7a717a377481555ce413016e04324

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 011f2f2ee15afaf2e1e2f941110a0b1eab7f2bf7497136a1711769e640eb61c5
MD5 9eca6d403ed486e67ddd670e5d049579
BLAKE2b-256 ffb2f1de23b9158fb276d76c732eee56dfba708a85270e74936ddcda4a82d3cd

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 342c53efa886db6e970369c4a504c6687dfd614e618ee907172141f487692f35
MD5 fe8051c77996441ada2b45bfabbcbc88
BLAKE2b-256 d1016286696cafd45ceef79ab5c62fcc524a270f1db5cd4f8705ec376a998e15

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp314-cp314-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 33cd3f3a4e4cf4d0b4f0d6114dec99f83a7bad4776d7200cc6dde4a1347329ec
MD5 c99d54db7a694e1e7b7dacdeff8083f8
BLAKE2b-256 786f5105c30c3e940049693c242941a66e80b7f1a9f02e9875a1d6f8a542a412

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 f460c478ebc9496985742113b0fe2c2020923dfcc4f71369f536bc95ca52c912
MD5 a1280c6f1108cfee8df8ff395e0c63a3
BLAKE2b-256 c92378fd53868e41f4887c55fc0113d29e6461b8d56a98eb2cb7310b6e1b3b0c

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 ebe5ed7614190a5c4fb25d5cd07edc2c9959a484fb446f2aed3788b6295c3842
MD5 834fa91f516038505933b9e3931e5489
BLAKE2b-256 910bc167b2c4eed70e74e974411fac46f1ba74944fd5b37e35b3321eba4a6416

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 35a31c7325afe3f2c2c968176a9f505d9fcb0435fbde54ea841337cecd1bd71b
MD5 40537701c41ccfb1c70b59f941353d3a
BLAKE2b-256 73fcf845c7cbb8839509a1a46e3859eab79d2ac622ed89f83aae949398f540cd

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp313-cp313-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 b0051c89b52fa139f51e1919a438607c5055567c8fbb07aadd635176939e5b4c
MD5 bf01bee99e9bcbcac9cff9d53208c719
BLAKE2b-256 7188a62507553bf94ac5aa165ab509a4717f61b2a0c4eb7c73b1a47ff57f58da

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 3fb7ceb000d288ef23a46922fb7278c2bbaea28cd5d5571c5d838feac1888dff
MD5 1c3ae975189aa779897fdebd1bbdb643
BLAKE2b-256 29519f40411f4d50a455c1f46580f2f73a6019a515c539bff9e91c45e1c47559

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 fb1d904cad93f19c61186a9dc02a460090efcba00904e205e0f4512edcd9b3d3
MD5 21441ad5e6ecba7f3950c9583be8f0f8
BLAKE2b-256 f610f9b1071671a4aa103e02c29406788b51ff6b48fce2eb4a416b91256abc82

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5b91fa22caa10c3fc2df0354facacf12b5b8327cb4ba070e8d1fe148046508e0
MD5 b8b88a6297105976a2c36668541f68d7
BLAKE2b-256 15977c978f6796c3702f4cb1882904118043b4ccb6a7814dc43656e236d85f17

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp312-cp312-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 c4e77c3997f793bd1f2367dd5ba2fbf7b2cf1624a778faa1c49d4f618a2a7a18
MD5 ce261d95504aaea5956dc347e7c5f079
BLAKE2b-256 d3bfa0af10cf877681aa4fa7df2b96910e362f03b584c15296c4a88f4e8da744

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fdf7c14a6a5295886d82e3eb7560c047d5674fdb71fd360e836fa8a02a32f20e
MD5 c1e2d8d9119edbb5f5f8ade6daea476e
BLAKE2b-256 b4cece8a04dd75c019802e991519132a028e220374c6edd4e00a1934b5db1725

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 e47acafc4abd62a7376e198c1707dda49b31924f34673f12e7ea0598c62f1ac3
MD5 1ebcdcd91d691de701c28eeece0ac2eb
BLAKE2b-256 c65694046f5066bcc370f3e102512b73812dd9a8e4ed95aca6c30072898f2ecd

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a947ddb90546f3b7925f99471cbf3be98071a81d3667ab0bf78283a4b5eef721
MD5 039cc0061669367362ad95dc543d2186
BLAKE2b-256 c9ba24a415b570c5bd09303f8afaa593a748626160125a32374a03302d4a26ee

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp311-cp311-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 21249dcf5391652cf347cc682c2887b3ff046a8e5995ac3c6ed7a15efd4d5823
MD5 690fa6036bf0c2e8d84b7e4a6e1df69a
BLAKE2b-256 2a64a06ae552859f9674fe6dbc1d31cf694e64692c46f1e80353d911bb426790

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7cd03958c9cf63e4c417fc21838448320d0299c94b05c2c4e714870670d1086a
MD5 4787adbf0b82c9915a1d3045a67039ca
BLAKE2b-256 5e3c68982481ff7e09970d55f5128489e82602d5366ac0c3d8b9830c0554c0dc

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 8cfdb19cfca32eb0f1dce78899f4d3e6a9dc3332d77db699b500fe43675052c4
MD5 9161c25da0c71265ee331e2d502367f0
BLAKE2b-256 27afc7be0101a229e3887499b3c236f04b50feb2a97d8947531cf1f7d5861dca

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1b4170d994bd6273130ae035439bc4a44b908a89a8be476b2872cccbf066da4
MD5 ba1b650767172f3e251add4db6bcffa7
BLAKE2b-256 b695c12c1822dcc53a3859d2892356ed506fda58e04f040e75c83f6dd1ccd087

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.1-cp310-cp310-macosx_10_14_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.1-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 1afd84b95c58b71404e062b60fb4ddf1ef483fd896f2525e00b720731ada8a57
MD5 e6ddcc683ad3da841534c0bd59726d58
BLAKE2b-256 eb77a6ccc88d64c3f05f60eaaace015efc1dd20a593c872ea5e9aa3198a54504

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