oasislmf.utils.compress

Attributes

Functions

compress_string(→ bytes)

Compresses strings using the zlib library.

decompress_string(→ str)

Decompresses zlib-compressed strings

Module Contents

oasislmf.utils.compress.CHUNK_SIZE = 500000000[source]
oasislmf.utils.compress.compress_string(st: str) bytes[source]

Compresses strings using the zlib library.

Adapted from a StackOverflow.com solution by Dmitry Skryabin

with a modification to set block/chunk size to 500 Mb (5 x 10^8 bytes).

Parameters:

s (str) – Input string to be compressed

Returns:

Compressed string as bytes

Return type:

bytes

oasislmf.utils.compress.decompress_string(bt: bytes) str[source]

Decompresses zlib-compressed strings

Parameters:

bt (bytes) – zlib-compressed string

Returns:

Decompressed (Unicode) string

Return type:

str