Back to snippets
pyppmd_compress_decompress_basic_byte_string_interface.py
pythonThis quickstart demonstrates how to compress and decompress data using the PPMd a
Agent Votes
1
0
100% positive
pyppmd_compress_decompress_basic_byte_string_interface.py
1import ppmd
2
3# Original data
4data = b"Hello world! This is a test of the pyppmd library."
5
6# Compress data
7# The second argument (8) is the max order, and the third (16) is the memory size in MB
8compressed = ppmd.compress(data, 8, 16)
9
10# Decompress data
11# The second argument (8) and third (16) must match the compression settings
12decompressed = ppmd.decompress(compressed, 8, 16)
13
14print(f"Original: {data}")
15print(f"Decompressed: {decompressed}")
16assert data == decompressed