File: README.md

package info (click to toggle)
python-zipfile-zstd 0.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,300 kB
  • sloc: python: 187; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# zipfile-zstd
[![PyPI](https://img.shields.io/pypi/v/zipfile-zstd)](https://pypi.org/project/zipfile-zstd/)

Monkey patch the standard `zipfile` module to enable Zstandard support.

Based on [`zipfile-deflate64`](https://github.com/brianhelba/zipfile-deflate64), which provides similar functionality but for the `deflate64` algorithm. Unlike `zipfile-deflate64`, this package supports both compression and decompression.

Requires [`python-zstandard`](https://github.com/indygreg/python-zstandard) for libzstd bindings.

## Installation
```bash
pip install zipfile-zstd
```

## Usage
Anywhere in a Python codebase:
```python
import zipfile_zstd  # This has the side effect of patching the zipfile module to support Zstandard
```

Alternatively, `zipfile_zstd` re-exports the `zipfile` API, as a convenience:
```python
import zipfile_zstd as zipfile

zipfile.ZipFile(...)
```

Compression example:
```python
import zipfile_zstd as zipfile

zf = zipfile.ZipFile('/tmp/test.zip', 'w', zipfile.ZIP_ZSTANDARD, compresslevel=19)
zf.write('large_file.img')
```

Dictionaries and advanced compression parameters are not supported, sorry.