Utility for randomly accessing DEFLATE-compressed data
Project description
ZRAN
Random read access for ZLIB, GZIP and DEFLATE file formats
Description
zran is a Python extension that wraps the zran library, which was created by Mark Adler (the creator of zlib). This utility will create an index that will allow you to begin decompressing DEFLATE-compressed data (ZLIB, GZIP, or DEFLATE format) from compression block boundaries on subsequent reads. This effectively allows you to randomly access DEFLATE-compressed data once the index is created.
Installation
zran can be installed in your preferred Python environment via pip:
python -m pip install zran
Currently, only macOS/Linux x86_64 and ARM64 architectures are supported. Please open an issue or submit a PR if you would like to see support for other platforms!
Usage
To use zran, you need to:
- Create an index for a compressed file
- Save this index
- Use this index to access the data on subsequent reads
To create and save the index:
import zran
with open('compressed.gz', 'rb') as f:
compressed_file = f.read()
index = zran.Index.create_index(compressed_file)
This Index can be written to a file (index.to_file('index.dflidx')), or directly passed to zran.deompress:
start = 1000
length = 2000
data = zran.decompress(compressed_file, index, start, length)
That's it!
Contributing
We use the standard GitHub flow to manage contributions to this project. Check out this documentation if you are unfamiliar with this process.
You can install a development version of zran via pip as well:
git clone https://github.com/forrestfwilliams/zran.git
cd zran
python -m pip install .
Then, run pytest to ensure that all tests are passing. We use black with line-length 120 for formatting and ruff for linting. Please ensure that your code is correctly formatted and linted before submitting a PR. As far as I can tell, pip installing with the --editable command is not valid when the code needs to be compiled, so you will need to re-install the package if you make any changes.
Similar Projects
If you prefer to work in the C programming language, you may want to work directly with the zran source C code in the zlib library. Paul McCarthy's indexed_gzip library was a huge inspiration for this project, and in particular was a huge help while creating our setup.py file. If you plan to work exclusively with gzip files, you may be better served by the indexed_gzip library. However, this project has some unique functionality that sets it apart:
- Use of the most up-to-date version of the
zranC library - Support for ZLIB, GZIP, and DEFLATE formatted data
- Greater visibility into the contents of indexes
- Compression of the indexes when written to a file, leading to smaller index file sizes
- The ability to modify the points contained within an index via the
Index.create_modified_index()method
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file zran-0.1.0.tar.gz.
File metadata
- Download URL: zran-0.1.0.tar.gz
- Upload date:
- Size: 128.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12181a2363e0afb84b9651b3374d4e685970d6435a2afa4fe105bbbbda990f32
|
|
| MD5 |
dd6d666edaf58963b30d23e600890195
|
|
| BLAKE2b-256 |
385ac6650a3f35f33207885d2e1da21aa7eb2e4b1ac0b5dac6d9bcdf505fc5ac
|
File details
Details for the file zran-0.1.0-cp311-cp311-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp311-cp311-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 585.3 kB
- Tags: CPython 3.11, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73bee5391bdc1533a38a00765fed1acdb240a9dc688da05f6a3ae8dad2166b1d
|
|
| MD5 |
cd4e206226bda9f363e92467b99df90c
|
|
| BLAKE2b-256 |
f4d3c6c73fb4c13ef6e6d2f7300d22a09edda49f07e7619aa886796c2a56a3a4
|
File details
Details for the file zran-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 592.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c08d2b74f84a8ada23aafda44aaccf1559e5e30def676b1334586fa8c8e3d46
|
|
| MD5 |
8984f0157abdeefa7bcc8c8e0cce689a
|
|
| BLAKE2b-256 |
169588c6f2ab83ad9d642459ecc6d450685f7f3489d66d304298efc0038c6710
|
File details
Details for the file zran-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: zran-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 198.5 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
188208f784388e4eacfff3fcdfe7138a049041d55dfe92d943c5499fad892eb1
|
|
| MD5 |
c24bfe985c1d705ec7bbd091f6e4118b
|
|
| BLAKE2b-256 |
499a69b16c2194014ebbe5be4aa100a0299df79623d5d510fda2af6f6d3df7d8
|
File details
Details for the file zran-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 204.1 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8f7b58ef157abb9b0a0115567a583fb14a00e4ff78d74914432082f4d134022
|
|
| MD5 |
0260c9c89bce9dbdcbdb2566e869bdae
|
|
| BLAKE2b-256 |
ce99d8ace30a2a52cb1b91606e0ceb534978e09d3c8752c05459637d91079354
|
File details
Details for the file zran-0.1.0-cp310-cp310-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp310-cp310-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 549.8 kB
- Tags: CPython 3.10, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d61c6575642c90a42a0afadf6097081426a748a1e0a0c3d5d64a003f07a504a
|
|
| MD5 |
f4de788c5162fda853d8e77423a0bf94
|
|
| BLAKE2b-256 |
c373aafc91e15995acd9b2e5a055ac471d722aa2a6a2705d04dd9af60991fbe9
|
File details
Details for the file zran-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 549.3 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39beee0212d639d8f15c706727717719d379c132fd0b316e9cb51dbe40eb8f74
|
|
| MD5 |
f953c5c381f85d87e2a4badbb5252f56
|
|
| BLAKE2b-256 |
8c94a103bd9423faade4a3a8dc97ade8e64762e4c86a1b31b5131dfc49d6078b
|
File details
Details for the file zran-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: zran-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 197.9 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aaafd9fe36a29496c1176a97242397b7807bd4211a9c0639ff9654679d22233a
|
|
| MD5 |
f417e919fff9c280df63cdb769830a68
|
|
| BLAKE2b-256 |
d1f343dc03234c9852d6b4e50ee8bd3486c0d1c49de37948d677578af1b67cc7
|
File details
Details for the file zran-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 203.3 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16a20872afae20df16554e9df2ec0d17eecc18e454b30d4cdc44e5a303e36e7d
|
|
| MD5 |
13c95cd457b13b460f8cda3914c5ff1b
|
|
| BLAKE2b-256 |
b09b0395ba43bfa28ac43cc9b57749bba90411e2e856d285a1511622e4d02694
|
File details
Details for the file zran-0.1.0-cp39-cp39-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp39-cp39-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 552.6 kB
- Tags: CPython 3.9, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae09a23cc5e090cf18257a40aedf97b2e54b675d9c8d131a5cedb94a2a1ddd58
|
|
| MD5 |
577757b63826f631419f94b729da8908
|
|
| BLAKE2b-256 |
5a3e5d65a5fcc73208b58b6a77982d90661eebe04b1a6e333fa9ddbeb4492675
|
File details
Details for the file zran-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 551.7 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
986ff5acba757f116e67c20b972628056f20d66a1a3cf0c51d42c2970e80ab4a
|
|
| MD5 |
4c064fbe0faa1be9d769a3a9d83c8f97
|
|
| BLAKE2b-256 |
c833e2e361f91cd61115d17dacf0ef4692cdee76b9cb50e406c4bf9b63d70e78
|
File details
Details for the file zran-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: zran-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 198.5 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75a867ce3bce3ee084da629cbc636f631d6e2cf9832dec4586d83b855e72ab80
|
|
| MD5 |
16ead1e5e5dc80024b50ed451b4d690c
|
|
| BLAKE2b-256 |
3a8ac0d2dd45811af27b2651d4ee4a18e78cea4b735dddc223305448b066012a
|
File details
Details for the file zran-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 203.7 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c12d4b7cf5308588887b66ed0071574f894814b560c1151165a9e5da03081add
|
|
| MD5 |
6d3f4439ba4793e5e4ce7f3cce5358ca
|
|
| BLAKE2b-256 |
103876925a6fa01188e758901edf2adcdcd09b99e31381809ad0b2f89f87f1a5
|
File details
Details for the file zran-0.1.0-cp38-cp38-musllinux_1_1_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp38-cp38-musllinux_1_1_x86_64.whl
- Upload date:
- Size: 591.0 kB
- Tags: CPython 3.8, musllinux: musl 1.1+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8da15eb85b112fdd9a7a4b23db70938abe60d059c44f4f9f1966c8ee697f3a6b
|
|
| MD5 |
9e604c3238645c7e01ee7dfd5cd875e2
|
|
| BLAKE2b-256 |
2449302357b18b3e66e57a9f7aa2d2db30b91b1db949c72e1ecce74d31a259e2
|
File details
Details for the file zran-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 566.0 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
416bfe9dcbe1505bf902705d1dbd10339aa0f88cdd6e6eb6525a36f4f23d9183
|
|
| MD5 |
c6b9d31f8a3efa564abf0241a0527f16
|
|
| BLAKE2b-256 |
e2741e6716641b2992c18971a199ca32e7060ae68c49c0943167b6cb54369251
|
File details
Details for the file zran-0.1.0-cp38-cp38-macosx_11_0_arm64.whl.
File metadata
- Download URL: zran-0.1.0-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 198.7 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be83b2064062d5a872b9bd756a662571440426445ec0719ba4165acf8ac3bbf0
|
|
| MD5 |
03f1033e0e9d846cbdab31ad4149311d
|
|
| BLAKE2b-256 |
ab4cb910bdbb81da5024e761228a2fdd56aed42e8a87113e89afcdd37a4e4911
|
File details
Details for the file zran-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl.
File metadata
- Download URL: zran-0.1.0-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 203.5 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8263bf2c59516c58d1af9067e2faf3d201689495f7afea19745de991503312e
|
|
| MD5 |
681cab61b28dd668589636f839fd2493
|
|
| BLAKE2b-256 |
e0675e270ee1b3c44162712cc28f055fa730162aac86cd77dfb875764548dbe9
|