使用xdelta3的快速增量编码
xdelta3-accemate的Python项目详细描述
使用xdelta3的python中的快速增量编码。
要求
- python 3.5或3.6-现在是2017年,无论如何,您现在应该使用python3.6了。
- linux-编译只在ubuntu上测试过,可能在其他平台上工作。
安装
pip install xdelta3
用法
importxdelta3value_one=b'wonderful string to demonstrate xdelta3, much of these two strings is the same.'value_two=b'different string to demonstrate xdelta3, much of these two strings is the same.'delta=xdelta3.encode(value_one,value_two)# delta is an unreadable byte string: b'\xd6\xc3 ... \x01different\n\x13F\x00'print(f'New string length: {len(value_two)}, delta length: {len(delta)}')value_two_rebuilt=xdelta3.decode(value_one,delta)ifvalue_two_rebuilt==value_two:print('Boo Ya! Delta encoding successful.')
(在安装了xdelta3的情况下,此代码应该按“原样”运行,只需将其复制到ipython或文件中并运行即可)
多快?
xdelta3 python是围绕xdelta 3.1.1的薄包装。 这是一个高度优化的C库,用于增量计算和压缩。 它可以对增量进行编码,并在550万个字符串中进行5次小的更改后再次解码。 (莎士比亚全集)大约10毫秒(或30毫秒,最高压缩水平)。繁荣。 见performance.py。