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
Metadata
Release files for light-compressor 0.0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 7.3 MB
Release files / light_compressor-0.0.2.2-cp314-cp314-win_amd64.whl
| Download URL | light_compressor-0.0.2.2-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 151.0 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0e9fad48c19d99ec12df3953a66adb00a28aaea99108e9b5a761c18b543eccab
|
|
BLAKE2b-256 checksum How to use checksums |
49708fdf27bdb9381188dbc44ab076f46e0743a18fe15de518401853a6cc80fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp314-cp314-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 978.1 kB |
| Tags | CPython 3.14 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
3392af47e8a0a24578661d0c88cc3dfd0d8814d7d67aeb976b9c41200696a35a
|
|
BLAKE2b-256 checksum How to use checksums |
08539b18201b6ddb8ebda8205ba65820b53f9c57df53bd4b5f52c4f148112c00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | light_compressor-0.0.2.2-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 168.3 kB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
845498f3f04e108698ebabf96ba9e8cb69f8a1cc109a297f85da15ed4c572c27
|
|
BLAKE2b-256 checksum How to use checksums |
252dfecd6d8cec5dc38f0d72a434fb61ce3119edb8215f15aab1f6cf2cc09f1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp314-cp314-macosx_10_15_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp314-cp314-macosx_10_15_x86_64.whl |
|---|---|
| Size | 162.8 kB |
| Tags | CPython 3.14 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
a73400319f22b718acdfafff69a17ab3cea33c5d482a32d9944b160d82fcd77d
|
|
BLAKE2b-256 checksum How to use checksums |
b45592561d0e059c40b6e8a2febe619395a62e7423836558e9a8260f7af8b5a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp313-cp313-win_amd64.whl
| Download URL | light_compressor-0.0.2.2-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 147.4 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ca46def4d848f4c2adceae6f0a6cbf16d0ffb244088a4a64546bc9ac22c8d577
|
|
BLAKE2b-256 checksum How to use checksums |
3d0580043b303da5adb3387230ca1d3139fca5016c5a76fb45e4a85fe3c34afc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 991.0 kB |
| Tags | CPython 3.13 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
99ecbdc7e2abd5a45935552f4b8a19ba48eb6e21075ae4b84ad8de8d4b087598
|
|
BLAKE2b-256 checksum How to use checksums |
48d1aec9cce2c7316a4aee06f70bc4f787ffadb9dd0170bbf64dc18af811335f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | light_compressor-0.0.2.2-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 166.3 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c7c3bc6dea91672263e59ce702f65eafaf8e312054f38469e8e298b1cb61c783
|
|
BLAKE2b-256 checksum How to use checksums |
44e7a97688703e458e38697d2d8f8af6d42bbbde045b24651cf257d72f16878d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp313-cp313-macosx_10_14_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp313-cp313-macosx_10_14_x86_64.whl |
|---|---|
| Size | 162.3 kB |
| Tags | CPython 3.13 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
42c0153e99c06f9bf993efe7e10cbe6e93f90249062ebbb9dc7004785b2763dc
|
|
BLAKE2b-256 checksum How to use checksums |
8490d924870d83e7d992d0e24233b2df086986cbb449c39b1fdc0db96c06b346
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp312-cp312-win_amd64.whl
| Download URL | light_compressor-0.0.2.2-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 149.4 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c8d714c03cac5ce724bdf822dbe27c18708c0800ea962927b5180af32e410214
|
|
BLAKE2b-256 checksum How to use checksums |
46837a48e13c3a37811fba7b8d06c1b9419ebc9f7c727fb98424f40709ebee3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
0e071950b0463f1732f3a061f3b5e90113f3745db917375b727a75b634e83914
|
|
BLAKE2b-256 checksum How to use checksums |
b2182c1142ccf3e23436f5e8598933f19737f2c6e8c9187d894b777d89237e08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | light_compressor-0.0.2.2-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 169.0 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
17dd1624e77d787778ee347e35e793346b5bf75520cbb40347fa0de21298616a
|
|
BLAKE2b-256 checksum How to use checksums |
e410966a6cf23ef67728b32bc5568dbf9e2d5806f9ea7507dbf87df5b583d5dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp312-cp312-macosx_10_14_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp312-cp312-macosx_10_14_x86_64.whl |
|---|---|
| Size | 165.0 kB |
| Tags | CPython 3.12 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
4a344a0dfda4b8f651e609be92293b625c0473710c73834484351cba0aefd24a
|
|
BLAKE2b-256 checksum How to use checksums |
d1e9779dc848073fb21e5193293ebbb1f98ae449b3d38608aab07ce381e9821d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp311-cp311-win_amd64.whl
| Download URL | light_compressor-0.0.2.2-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 151.0 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
05d63414f2adb595c5944d9f48437d0a6e2ff2417ed224df094c2e458046bb93
|
|
BLAKE2b-256 checksum How to use checksums |
ab49db086f62d4b51e89ddceeb1834d87655cb09679733d6f21b70874e6a0205
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 956.0 kB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
92fef9f0a617a4a0d7bcb1bc02252148cb4662850454a943c64a7139b6a15323
|
|
BLAKE2b-256 checksum How to use checksums |
703b0f385181561c3e38964166f9ac1dbf2e3b4002ff26e146bb4ba08dfa4f58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | light_compressor-0.0.2.2-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 167.6 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3fb82297494680c829f8d69aee73b3b6ae2558a6f7984034bfcb5a0465d16b9d
|
|
BLAKE2b-256 checksum How to use checksums |
cfd10c3ffc0003b0682aeda56ee59883c5932b8a6d60e90c1de9748bb77672e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp311-cp311-macosx_10_14_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp311-cp311-macosx_10_14_x86_64.whl |
|---|---|
| Size | 163.3 kB |
| Tags | CPython 3.11 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
04ac2c2faaa34470810832324fb99dfafebd84edfe20fd1335d06aeccc95584b
|
|
BLAKE2b-256 checksum How to use checksums |
4f6093552b4f6257f5ca8ebd99d45acd3f73751ce924a1ce47f7bdb1a589604f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp310-cp310-win_amd64.whl
| Download URL | light_compressor-0.0.2.2-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 151.5 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e6f72511e3225322fc672e17a5a9ae9d06b69424b0e2ce20af5c761236e52cb6
|
|
BLAKE2b-256 checksum How to use checksums |
2a6b56802a1f56fc50be410534e665282e0ecd3ae4530d1c5e3abfd1d022b1af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl |
|---|---|
| Size | 907.3 kB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
be6504ca4e878235892a491cc7eed40908d775802d3585f08deb2dcdd1ff177f
|
|
BLAKE2b-256 checksum How to use checksums |
72b99ee807ad22f1830ab3d3d59715a4fa0a41232ed56a68a5500e05b50923d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | light_compressor-0.0.2.2-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 168.7 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
c359aa8c3b96e71927c9ee2c1506f48ccd5f78a6ba20e69e9d9f4ac79131aba9
|
|
BLAKE2b-256 checksum How to use checksums |
af092416a9a727cf0179fa91e734bab1f5df56071a9c5d73e1c4437350bf5780
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / light_compressor-0.0.2.2-cp310-cp310-macosx_10_14_x86_64.whl
| Download URL | light_compressor-0.0.2.2-cp310-cp310-macosx_10_14_x86_64.whl |
|---|---|
| Size | 164.3 kB |
| Tags | CPython 3.10 macOS 10.14+ x86-64 |
|
SHA-256 checksum How to use checksums |
a9a366ab7672ee5d069b43de4183ba78beb0ee177bcfea096ab6ed1f209ad262
|
|
BLAKE2b-256 checksum How to use checksums |
7c23b81408a4dee8554e2d5dc6b1a03529aac3ea8ae046614d635dd93efc8fa5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|