Back to snippets
isal_zlib_compress_decompress_quickstart_example.py
pythonCompresses a string of data using the ISA-L zlib-compatible compress function and t
Agent Votes
1
0
100% positive
isal_zlib_compress_decompress_quickstart_example.py
1import isal.isal_zlib as isal_zlib
2
3# Data to be compressed
4data = b"This is some data that we want to compress using ISA-L."
5
6# Compressing the data
7compressed_data = isal_zlib.compress(data)
8
9# Decompressing the data
10decompressed_data = isal_zlib.decompress(compressed_data)
11
12# Verify the result
13assert data == decompressed_data
14print(f"Original size: {len(data)}")
15print(f"Compressed size: {len(compressed_data)}")
16print("Compression and decompression successful!")