Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for modname, func in [("pylz4", pylz4.compress), ("rustlz4", rustlz4.compress)]:
timer = timeit.Timer(functools.partial(func, data))
elapsed = timer.timeit(number=number)
perf = size * number / elapsed / 1e6
name = "%s.%s" % (modname, func.__name__)
print("%24s: %8.2f MB/s" % (name, perf))
for modname, func in [("pylz4", pylz4.compressHC), ("rustlz4", rustlz4.compresshc)]:
timer = timeit.Timer(functools.partial(func, hcdata))
elapsed = timer.timeit(number=number)
perf = size * number / elapsed / 1e6
name = "%s.%s" % (modname, func.__name__)
print("%24s: %8.2f MB/s" % (name, perf))
data = pylz4.compress(data)
for modname, func in [("pylz4", pylz4.decompress), ("rustlz4", rustlz4.decompress)]:
timer = timeit.Timer(functools.partial(func, data))
elapsed = timer.timeit(number=number)
perf = size * number / elapsed / 1e6
name = "%s.%s" % (modname, func.__name__)
print("%24s: %8.2f MB/s" % (name, perf))
def __init__(self, img, angle):
self.img_buf = lz4.compress(img)
self.img_shape = img.shape
self.angle = angle
def process_document(self, session, doc):
data = doc.get_raw(session)
new = lz4.compress(data)
return StringDocument(new, self.id, doc.processHistory,
parent=doc.parent, filename=doc.filename)
def save(self, fname):
with open(fname, 'w') as f:
f.write(lz4.compress(pickle.dumps(self)))