Metadata-Version: 2.4
Name: simple-zstd
Version: 0.1.2
Project-URL: Repository, https://github.com/chuanconggao/SimpleZstd/
Author-email: Chuancong Gao <chuanconggao@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: zstandard>=0.21.0
Description-Content-Type: text/markdown

# SimpleZstd

This library provides simple Pythonic interface of [`zstd`](https://facebook.github.io/zstd/) algorithm like Python's builtin `gzip` library, by wrapping the [`zstandard`](https://github.com/indygreg/python-zstandard) library.
- Note that it matches the same interface of [builtin `zstd` support](https://docs.python.org/3.14/whatsnew/3.14.html#pep-784-adding-zstandard-to-the-standard-library) in Python 3.14+ standard library.

Further more, it provides builtin session support to take advantage of `zstd`'s powerful training mode without additional user effort, by auto collecting training samples (10 by default) during compression/decompression.

``` python
In [1]: c = open("poetry.lock").read().encode("utf-8")

In [2]: len(c)
Out[2]: 73946

In [3]: from simple_zstd import compress, decompress

In [4]: for i in range(10):
   ...:     x = compress(c)
   ...:     print(len(x), len(x) / len(c))
   ...:     assert decompress(x) == c
   ...:
22259 0.3010169583209369
22259 0.3010169583209369
22259 0.3010169583209369
22259 0.3010169583209369
22259 0.3010169583209369
7123 0.09632704946853109
7123 0.09632704946853109
7123 0.09632704946853109
7123 0.09632704946853109
7123 0.09632704946853109
```

Note that user can also choose to have dedicated session instead of default one.

``` python
In [1]: c = open("poetry.lock").read().encode("utf-8")

In [2]: from simple_zstd import Session

In [3]: session = Session()

In [4]: x = session.compress(c)

In [5]: assert session.decompress(x) == c
```

For simpler usage, you can also just import `zstd` instead of `simple_zstd`.

Dictionary is exposed under session object. You need to store it for later decompression by passing when creating session.
