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.0-cp311-cp311-win_amd64.whl (121.7 kB view details)

Uploaded CPython 3.11Windows x86-64

light_compressor-0.0.2.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (774.5 kB view details)

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

light_compressor-0.0.2.0-cp311-cp311-macosx_11_0_arm64.whl (138.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

light_compressor-0.0.2.0-cp311-cp311-macosx_10_14_x86_64.whl (142.1 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

light_compressor-0.0.2.0-cp310-cp310-win_amd64.whl (124.2 kB view details)

Uploaded CPython 3.10Windows x86-64

light_compressor-0.0.2.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (738.4 kB view details)

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

light_compressor-0.0.2.0-cp310-cp310-macosx_11_0_arm64.whl (140.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

light_compressor-0.0.2.0-cp310-cp310-macosx_10_14_x86_64.whl (142.8 kB view details)

Uploaded CPython 3.10macOS 10.14+ x86-64

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 b834f781afda8db7378149c772db3ffe6e492ac15ba560157f365c4548223600
MD5 0c40fb243b18ea4a0e2f0d4bb321b005
BLAKE2b-256 8a9e1d5483b8badbb7e3543dfaa1eb6aa05654a7aeddbfaf9980cb27d8105e9e

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 055e5fd5a3bb45484c390cdb2d358816622d25fa72e0a50b77d0692e5ccbb566
MD5 562bcf2b75e0682c65c206a9726d2e40
BLAKE2b-256 a9e1ad749290b2b974253c4d1396bcdf2c2a2a4c0cc563b5f11dbdf34cda3d3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c3439d72d29dfb5174b5acb8d16770e7807f1e7643ee120efc741ce9755c2a3b
MD5 79e7f4de97cef65cafb9bd25017808bf
BLAKE2b-256 de033a5d2e26db11519c3bfe78b86003f4e1a357f4804181ced8d32f6f06b8a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.0-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 ee51299ec97477d7b2e714f27732fca13f72e492dd3e8708621a8a00b4302ae5
MD5 17b3f179bf01c61a5cf1684d0952a1fc
BLAKE2b-256 291a37647c7102d455ddd78ab8c4df279802aa454467370acee9a48e6e1898da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 79c5d99f21aeccb9f4538988bdff9a4b4cb6e6450823779d5c0864e2ef5102b1
MD5 8d45c6fc6d45401096db7a5c7115c86a
BLAKE2b-256 249080b988f3f6e16a6fdfc5757e28baadf99f06ac09e0f95e53f1f79c54c96e

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b19166cb87b7c9df41be8469cd2e20a95b99f6bc26ceadbd40fd748263e87546
MD5 7883676172ffa6b782583344f6450980
BLAKE2b-256 0c7fc7c8063d6a59e7be276bf353406b4201d67c67b08b97fa951a590aab7eba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f56a594f72978b5c62576fd0054055b17db3391f9b7b8020418ef0d6adc07bf
MD5 24be1708104aa692db5f2638df8b4d12
BLAKE2b-256 74087997ff6ff530077fa21714188585180c2410a0d511dc3717e7981658646d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.0-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 0e40ea9a141dd79bca60f0bc9d21782109195b0d80237ce4eebdd3e0c4e71733
MD5 db32e86592912484f9e6d6a5df01c914
BLAKE2b-256 af4a7cebb07ce65baca6db7c9d8d7f1c4c24984297cc309ba3c8e7daa13c2476

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