Skip to main content

Utility for randomly accessing DEFLATE-compressed data

Project description

ZRAN

Random read access for gzip and zip files

Description

zran is a Python extension that wraps the zran library, which was created by Mark Adler (the creator of zlib). This utility allows you to create an index that allows you begin decompressing DEFLATE-compressed data (ZLIB, GZIP, or DEFLATE format) from compression block boundaries. This effectively allows you to randomly access DEFLATE-compressed data once the index is created.

Installation

In your preferred python environment:

git clone https://github.com/forrestfwilliams/zran.git
cd zran
python -m pip install .

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.

Usage

To use zran, you need to:

  1. Create an index for a compressed file
  2. Save this index
  3. 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!

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

zran-0.0.2-cp311-cp311-musllinux_1_1_x86_64.whl (584.0 kB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

zran-0.0.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (590.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

zran-0.0.2-cp311-cp311-macosx_11_0_arm64.whl (192.8 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

zran-0.0.2-cp311-cp311-macosx_10_9_x86_64.whl (198.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

zran-0.0.2-cp310-cp310-musllinux_1_1_x86_64.whl (546.5 kB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

zran-0.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (547.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

zran-0.0.2-cp310-cp310-macosx_11_0_arm64.whl (192.2 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

zran-0.0.2-cp310-cp310-macosx_10_9_x86_64.whl (197.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

zran-0.0.2-cp39-cp39-musllinux_1_1_x86_64.whl (550.1 kB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

zran-0.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (549.9 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

zran-0.0.2-cp39-cp39-macosx_11_0_arm64.whl (193.0 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

zran-0.0.2-cp39-cp39-macosx_10_9_x86_64.whl (198.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

zran-0.0.2-cp38-cp38-musllinux_1_1_x86_64.whl (588.5 kB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

zran-0.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (562.4 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

zran-0.0.2-cp38-cp38-macosx_11_0_arm64.whl (193.1 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

zran-0.0.2-cp38-cp38-macosx_10_9_x86_64.whl (198.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page