def lz4_compress(packet, level): if level >= 9: return level | LZ4_FLAG, compressHC(packet) #clamp it: 0->17, 1->12, 2->7, 3->2, >=4->1 if level <= 2: #clamp it: 0->17, 1->12, 2->7, 3->2, >=4->1 accel = max(1, 17 - level * 5) return level | LZ4_FLAG, LZ4_compress_fast(packet, accel) return level | LZ4_FLAG, LZ4_compress(packet)
def do_test_rountrip(i_data, c_data=None): from lz4 import LZ4_compress, LZ4_uncompress #@UnresolvedImport c = LZ4_compress(i_data) if c_data is not None: assert c_data == c, "expected compressed data to look like %s, but got %s" % ( hl(c_data), hl(c)) d = LZ4_uncompress(c) assert d == i_data, "expected decompressed data to look like original %s, but got %s" % ( hl(i_data), hl(d))
def lz4_compress(packet, level): if level>=9: return level | LZ4_FLAG, compressHC(packet) return level | LZ4_FLAG, LZ4_compress(packet)
def lz4_compress(packet, level): return level | LZ4_FLAG, LZ4_compress(packet)
def lz4_compress(packet, level): if _memoryview and isinstance(packet, _memoryview): packet = packet.tobytes() return level | LZ4_FLAG, LZ4_compress(packet)