samuelcolvin / xdelta3-python

Fast delta encoding in python using xdelta3
Other
34 stars 15 forks source link

delta size different from xdelta-cli #8

Closed ghost closed 6 years ago

ghost commented 6 years ago

Environment

Reproduce

echo $'11111" > 1.txt

echo $'000000\n000000\n000000\n000000\n000000\n000000\n000000\n' > 2.txt

xdelta3 -e -s 1.txt 2.txt delta

in python had data1 from 1.txt and data2 from 2.txt writes xdelta3.encode(data1, data2) to py_delta

Question

py_delta is 20B, but delta is 39B. use xdelta3 -d -s 1.txt delta 3.txt or xdelta3 -d -s 1.txt py_delta 3.txt all get the same result without problem.

It works fine, but I'm still unnecessarily worrying, did I miss some arguments with xdelta3?
And how to get the same result?

samuelcolvin commented 6 years ago
from pathlib import Path
import xdelta3

Path('delta').read_bytes()
b'\xd6\xc3\xc4\x00\x05\x02\r2.txt//1.txt/\x04\x132\x00\x03\x05\x02\xd76\x0810\n\n\xa4\x02\x13*\x02\x00\x00'

xdelta3.encode(Path('1.txt').read_bytes(), Path('2.txt').read_bytes())
b'\xd6\xc3\xc4\x00\x00\x00\x0f2\x00\x03\x05\x020\n\n\xa4\x02\x13*\x02\x00\x00'

You see that the xdelta3 cli includes data about the files names while this python package does not.

The rest of the deltas are not exactly identical but then my versions do not match and the compression level may not be the same.