Defined in uproot.compression on line 482.
- uproot.compression.compress(data, compression)
data (bytes, memoryview, or NumPy array) – Data to compress.
compression (uproot.compression.Compression) – Algorithm and level to use in compressing the data.
compressionand return a bytes object (or the original object in some circumstances).
This function generates ROOT’s 9-byte compression headers (17 bytes for LZ4 because it includes a checksum), with multiple blocks for each 2**24 - 1 bytes of input. The return value has all blocks concatenated into a single bytes object, and the splitting into multiple blocks is necessary because the compression headers can only specify uncompressed and compressed sizes up to 2**24 - 1.
If the compression level (
compression.level) is zero or the compressed output would be larger than the input, the input is returned instead, in whatever format (bytes, memoryview, or NumPy array) it was provided.