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.2-cp314-cp314-win_amd64.whl (151.0 kB view details)

Uploaded CPython 3.14Windows x86-64

light_compressor-0.0.2.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (978.1 kB view details)

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

light_compressor-0.0.2.2-cp314-cp314-macosx_11_0_arm64.whl (168.3 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

light_compressor-0.0.2.2-cp314-cp314-macosx_10_15_x86_64.whl (162.8 kB view details)

Uploaded CPython 3.14macOS 10.15+ x86-64

light_compressor-0.0.2.2-cp313-cp313-win_amd64.whl (147.4 kB view details)

Uploaded CPython 3.13Windows x86-64

light_compressor-0.0.2.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (991.0 kB view details)

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

light_compressor-0.0.2.2-cp313-cp313-macosx_11_0_arm64.whl (166.3 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

light_compressor-0.0.2.2-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.2-cp312-cp312-win_amd64.whl (149.4 kB view details)

Uploaded CPython 3.12Windows x86-64

light_compressor-0.0.2.2-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.2-cp312-cp312-macosx_11_0_arm64.whl (169.0 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

light_compressor-0.0.2.2-cp312-cp312-macosx_10_14_x86_64.whl (165.0 kB view details)

Uploaded CPython 3.12macOS 10.14+ x86-64

light_compressor-0.0.2.2-cp311-cp311-win_amd64.whl (151.0 kB view details)

Uploaded CPython 3.11Windows x86-64

light_compressor-0.0.2.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (956.0 kB view details)

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

light_compressor-0.0.2.2-cp311-cp311-macosx_11_0_arm64.whl (167.6 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

light_compressor-0.0.2.2-cp311-cp311-macosx_10_14_x86_64.whl (163.3 kB view details)

Uploaded CPython 3.11macOS 10.14+ x86-64

light_compressor-0.0.2.2-cp310-cp310-win_amd64.whl (151.5 kB view details)

Uploaded CPython 3.10Windows x86-64

light_compressor-0.0.2.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl (907.3 kB view details)

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

light_compressor-0.0.2.2-cp310-cp310-macosx_11_0_arm64.whl (168.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

light_compressor-0.0.2.2-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.2-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 0e9fad48c19d99ec12df3953a66adb00a28aaea99108e9b5a761c18b543eccab
MD5 6c6b3d5138a30ebc75b8e879f0c7129d
BLAKE2b-256 49708fdf27bdb9381188dbc44ab076f46e0743a18fe15de518401853a6cc80fc

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.2-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.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 3392af47e8a0a24578661d0c88cc3dfd0d8814d7d67aeb976b9c41200696a35a
MD5 04f699952cda6d2549ce8571e8e3a504
BLAKE2b-256 08539b18201b6ddb8ebda8205ba65820b53f9c57df53bd4b5f52c4f148112c00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 845498f3f04e108698ebabf96ba9e8cb69f8a1cc109a297f85da15ed4c572c27
MD5 fde5a8af09fb753c602b474cca7c29c7
BLAKE2b-256 252dfecd6d8cec5dc38f0d72a434fb61ce3119edb8215f15aab1f6cf2cc09f1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp314-cp314-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a73400319f22b718acdfafff69a17ab3cea33c5d482a32d9944b160d82fcd77d
MD5 f03422afdfcbe2c820af1a20650f5153
BLAKE2b-256 b45592561d0e059c40b6e8a2febe619395a62e7423836558e9a8260f7af8b5a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ca46def4d848f4c2adceae6f0a6cbf16d0ffb244088a4a64546bc9ac22c8d577
MD5 4e39314e6640a0f8137b7cb00e6ec0c9
BLAKE2b-256 3d0580043b303da5adb3387230ca1d3139fca5016c5a76fb45e4a85fe3c34afc

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.2-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.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 99ecbdc7e2abd5a45935552f4b8a19ba48eb6e21075ae4b84ad8de8d4b087598
MD5 4eb1e5e6df814c4f6bd708106e1d374a
BLAKE2b-256 48d1aec9cce2c7316a4aee06f70bc4f787ffadb9dd0170bbf64dc18af811335f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c7c3bc6dea91672263e59ce702f65eafaf8e312054f38469e8e298b1cb61c783
MD5 8ae8594a00e2ecc738ffb526bb66d416
BLAKE2b-256 44e7a97688703e458e38697d2d8f8af6d42bbbde045b24651cf257d72f16878d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp313-cp313-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 42c0153e99c06f9bf993efe7e10cbe6e93f90249062ebbb9dc7004785b2763dc
MD5 dce15f9805d298c7caa7464e3822185a
BLAKE2b-256 8490d924870d83e7d992d0e24233b2df086986cbb449c39b1fdc0db96c06b346

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c8d714c03cac5ce724bdf822dbe27c18708c0800ea962927b5180af32e410214
MD5 e284af8fa7d483bc192bee9fe8575355
BLAKE2b-256 46837a48e13c3a37811fba7b8d06c1b9419ebc9f7c727fb98424f40709ebee3a

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.2-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.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 0e071950b0463f1732f3a061f3b5e90113f3745db917375b727a75b634e83914
MD5 48ab9b491bb5f48617557a25ef810caf
BLAKE2b-256 b2182c1142ccf3e23436f5e8598933f19737f2c6e8c9187d894b777d89237e08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17dd1624e77d787778ee347e35e793346b5bf75520cbb40347fa0de21298616a
MD5 149ec10209eee2d2f1d94cab07b21672
BLAKE2b-256 e410966a6cf23ef67728b32bc5568dbf9e2d5806f9ea7507dbf87df5b583d5dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp312-cp312-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 4a344a0dfda4b8f651e609be92293b625c0473710c73834484351cba0aefd24a
MD5 d8de8eae58f54683bb43a0991a83e595
BLAKE2b-256 d1e9779dc848073fb21e5193293ebbb1f98ae449b3d38608aab07ce381e9821d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 05d63414f2adb595c5944d9f48437d0a6e2ff2417ed224df094c2e458046bb93
MD5 c0efb663b08d47efa7d6b04dbfb0c04f
BLAKE2b-256 ab49db086f62d4b51e89ddceeb1834d87655cb09679733d6f21b70874e6a0205

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.2-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.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 92fef9f0a617a4a0d7bcb1bc02252148cb4662850454a943c64a7139b6a15323
MD5 d11651500cf352925bf76ea830c71f82
BLAKE2b-256 703b0f385181561c3e38964166f9ac1dbf2e3b4002ff26e146bb4ba08dfa4f58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3fb82297494680c829f8d69aee73b3b6ae2558a6f7984034bfcb5a0465d16b9d
MD5 edf53f34b147b774b29d0d6357d683ca
BLAKE2b-256 cfd10c3ffc0003b0682aeda56ee59883c5932b8a6d60e90c1de9748bb77672e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp311-cp311-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 04ac2c2faaa34470810832324fb99dfafebd84edfe20fd1335d06aeccc95584b
MD5 2f52c5fdadd8996dfc4ebf17d95e782a
BLAKE2b-256 4f6093552b4f6257f5ca8ebd99d45acd3f73751ce924a1ce47f7bdb1a589604f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e6f72511e3225322fc672e17a5a9ae9d06b69424b0e2ce20af5c761236e52cb6
MD5 6f2d0cc2a5b9c62418fbc267bc7d4cac
BLAKE2b-256 2a6b56802a1f56fc50be410534e665282e0ecd3ae4530d1c5e3abfd1d022b1af

See more details on using hashes here.

File details

Details for the file light_compressor-0.0.2.2-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.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
Algorithm Hash digest
SHA256 be6504ca4e878235892a491cc7eed40908d775802d3585f08deb2dcdd1ff177f
MD5 16de416c61f79c0b7d9fc4f35c2cd5e8
BLAKE2b-256 72b99ee807ad22f1830ab3d3d59715a4fa0a41232ed56a68a5500e05b50923d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c359aa8c3b96e71927c9ee2c1506f48ccd5f78a6ba20e69e9d9f4ac79131aba9
MD5 a83271ff3dd54664d2f6e6c6fea2323d
BLAKE2b-256 af092416a9a727cf0179fa91e734bab1f5df56071a9c5d73e1c4437350bf5780

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for light_compressor-0.0.2.2-cp310-cp310-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 a9a366ab7672ee5d069b43de4183ba78beb0ee177bcfea096ab6ed1f209ad262
MD5 8d21768c7ad4bcc150735ee32b411d76
BLAKE2b-256 7c23b81408a4dee8554e2d5dc6b1a03529aac3ea8ae046614d635dd93efc8fa5

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