BrotliCFFI

1.2.0.1 · active · verified Fri Apr 10

BrotliCFFI provides Python CFFI bindings to Google's high-performance Brotli compression library. It allows Python applications to leverage the Brotli compression algorithm efficiently across various Python interpreters, including PyPy. The current version is 1.2.0.1, and it maintains an active release cadence with regular updates to the underlying Brotli library and Python compatibility.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic compression and decompression of a byte string using `brotlicffi.compress()` and `brotlicffi.decompress()`.

import brotlicffi

original_data = b"This is some sample data that will be compressed using Brotli!"

# Compress data
compressed_data = brotlicffi.compress(original_data)
print(f"Original size: {len(original_data)} bytes")
print(f"Compressed size: {len(compressed_data)} bytes")

# Decompress data
decompressed_data = brotlicffi.decompress(compressed_data)

print(f"Decompressed data: {decompressed_data}")
assert original_data == decompressed_data
print("Compression and decompression successful!")

view raw JSON →