loongson/pypi/: cramjam-2.10.0 metadata and description
Thin Python bindings to de/compression algorithms in Rust
| author | Miles Granger <miles59923@gmail.com> |
| author_email | Miles Granger <miles59923@gmail.com> |
| description_content_type | text/markdown; charset=UTF-8; variant=GFM |
| keywords | compression,decompression,snappy,zstd,bz2,gzip,lz4,brotli,deflate,blosc2 |
| license | MIT |
| project_urls |
|
| provides_extras | dev |
| requires_dist |
|
| requires_python | >=3.8 |
| File | Tox results | History |
|---|---|---|
cramjam-2.10.0-cp310-cp310-manylinux_2_28_loongarch64.whl
|
|
# cramjam
[](https://github.com/python/black)
[](https://github.com/milesgranger/cramjam/actions/workflows/CI.yml)
[](https://pypi.org/project/cramjam)
[](https://anaconda.org/conda-forge/cramjam)
[](https://pepy.tech/project/cramjam)
[API Documentation](https://docs.rs/cramjam)
### Install
```commandline
pip install --upgrade cramjam # Requires no Python or system dependencies!
```
### CLI
A CLI interface is available as [`cramjam-cli`](https://github.com/cramjam/cramjam-cli)
### libcramjam
A Rust crate and C friendly library available at [libcramjam](https://github.com/cramjam/libcramjam)
---
Extremely thin and easy-to-install Python bindings to de/compression algorithms in Rust.
Allows for using algorithms such as Snappy, without any system or other python dependencies.
---
##### Benchmarks
Some basic benchmarks are available [in the benchmarks directory](./benchmarks/README.md)
---
Available algorithms:
- [X] Snappy `cramjam.snappy`
- [X] Brotli `cramjam.brotli`
- [X] Bzip2 `cramjam.bzip2`
- [X] Lz4 `cramjam.lz4`
- [X] Gzip `cramjam.gzip`
- [X] Zlib `cramjam.zlib`
- [X] Deflate `cramjam.deflate`
- [X] ZSTD `cramjam.zstd`
- [X] XZ / LZMA `cramjam.xz`
Experimental (Requires build from source enabling each feature):
- [X] Blosc2 `cramjam.experimental.blosc2`
- [X] ISA-L backend _(only on 64-bit targets)_
- [X] igzip `cramjam.experimental.igzip`
- [X] ideflate `cramjam.experimental.ideflate`
- [X] izlib `cramjam.experimental.izlib`
All available for use as:
```python
>>> import cramjam
>>> import numpy as np
>>> compressed = cramjam.snappy.compress(b"bytes here")
>>> decompressed = cramjam.snappy.decompress(compressed)
>>> decompressed
cramjam.Buffer(len=10) # an object which implements the buffer protocol
>>> bytes(decompressed)
b"bytes here"
>>> np.frombuffer(decompressed, dtype=np.uint8)
array([ 98, 121, 116, 101, 115, 32, 104, 101, 114, 101], dtype=uint8)
```
Where the API is `cramjam.<compression-variant>.compress/decompress` and accepts
`bytes`/`bytearray`/`numpy.array`/`cramjam.File`/`cramjam.Buffer` / `memoryview` objects.
**de/compress_into**
Additionally, all variants support `decompress_into` and `compress_into`.
Ex.
```python
>>> import numpy as np
>>> from cramjam import snappy, Buffer
>>>
>>> data = np.frombuffer(b'some bytes here', dtype=np.uint8)
>>> data
array([115, 111, 109, 101, 32, 98, 121, 116, 101, 115, 32, 104, 101,
114, 101], dtype=uint8)
>>>
>>> compressed = Buffer()
>>> snappy.compress_into(data, compressed)
33 # 33 bytes written to compressed buffer
>>>
>>> compressed.tell() # Where is the buffer position?
33 # goodie!
>>>
>>> compressed.seek(0) # Go back to the start of the buffer so we can prepare to decompress
>>> decompressed = b'0' * len(data) # let's write to `bytes` as output
>>> decompressed
b'000000000000000'
>>>
>>> snappy.decompress_into(compressed, decompressed)
15 # 15 bytes written to decompressed
>>> decompressed
b'some bytes here'
```
Render warnings:
<string>:86: (ERROR/3) Unexpected indentation.
[](https://github.com/python/black)
[](https://github.com/milesgranger/cramjam/actions/workflows/CI.yml)
[](https://pypi.org/project/cramjam)
[](https://anaconda.org/conda-forge/cramjam)
[](https://pepy.tech/project/cramjam)
[API Documentation](https://docs.rs/cramjam)
### Install
```commandline
pip install --upgrade cramjam # Requires no Python or system dependencies!
```
### CLI
A CLI interface is available as [`cramjam-cli`](https://github.com/cramjam/cramjam-cli)
### libcramjam
A Rust crate and C friendly library available at [libcramjam](https://github.com/cramjam/libcramjam)
---
Extremely thin and easy-to-install Python bindings to de/compression algorithms in Rust.
Allows for using algorithms such as Snappy, without any system or other python dependencies.
---
##### Benchmarks
Some basic benchmarks are available [in the benchmarks directory](./benchmarks/README.md)
---
Available algorithms:
- [X] Snappy `cramjam.snappy`
- [X] Brotli `cramjam.brotli`
- [X] Bzip2 `cramjam.bzip2`
- [X] Lz4 `cramjam.lz4`
- [X] Gzip `cramjam.gzip`
- [X] Zlib `cramjam.zlib`
- [X] Deflate `cramjam.deflate`
- [X] ZSTD `cramjam.zstd`
- [X] XZ / LZMA `cramjam.xz`
Experimental (Requires build from source enabling each feature):
- [X] Blosc2 `cramjam.experimental.blosc2`
- [X] ISA-L backend _(only on 64-bit targets)_
- [X] igzip `cramjam.experimental.igzip`
- [X] ideflate `cramjam.experimental.ideflate`
- [X] izlib `cramjam.experimental.izlib`
All available for use as:
```python
>>> import cramjam
>>> import numpy as np
>>> compressed = cramjam.snappy.compress(b"bytes here")
>>> decompressed = cramjam.snappy.decompress(compressed)
>>> decompressed
cramjam.Buffer(len=10) # an object which implements the buffer protocol
>>> bytes(decompressed)
b"bytes here"
>>> np.frombuffer(decompressed, dtype=np.uint8)
array([ 98, 121, 116, 101, 115, 32, 104, 101, 114, 101], dtype=uint8)
```
Where the API is `cramjam.<compression-variant>.compress/decompress` and accepts
`bytes`/`bytearray`/`numpy.array`/`cramjam.File`/`cramjam.Buffer` / `memoryview` objects.
**de/compress_into**
Additionally, all variants support `decompress_into` and `compress_into`.
Ex.
```python
>>> import numpy as np
>>> from cramjam import snappy, Buffer
>>>
>>> data = np.frombuffer(b'some bytes here', dtype=np.uint8)
>>> data
array([115, 111, 109, 101, 32, 98, 121, 116, 101, 115, 32, 104, 101,
114, 101], dtype=uint8)
>>>
>>> compressed = Buffer()
>>> snappy.compress_into(data, compressed)
33 # 33 bytes written to compressed buffer
>>>
>>> compressed.tell() # Where is the buffer position?
33 # goodie!
>>>
>>> compressed.seek(0) # Go back to the start of the buffer so we can prepare to decompress
>>> decompressed = b'0' * len(data) # let's write to `bytes` as output
>>> decompressed
b'000000000000000'
>>>
>>> snappy.decompress_into(compressed, decompressed)
15 # 15 bytes written to decompressed
>>> decompressed
b'some bytes here'
```
Render warnings:
<string>:86: (ERROR/3) Unexpected indentation.